Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/commande/modules_commande.php 3 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
      *  @param	DoliDB	$db     			Database handler
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of templates
50
-	 */
51
-	static function liste_modeles($db, $maxfilenamelength=0)
52
-	{
50
+     */
51
+    static function liste_modeles($db, $maxfilenamelength=0)
52
+    {
53 53
         // phpcs:enable
54
-		global $conf;
54
+        global $conf;
55 55
 
56
-		$type = 'order';
57
-		$list = array();
56
+        $type = 'order';
57
+        $list = array();
58 58
 
59
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$list = getListOfModels($db, $type, $maxfilenamelength);
59
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
+        $list = getListOfModels($db, $type, $maxfilenamelength);
61 61
 
62
-		return $list;
63
-	}
62
+        return $list;
63
+    }
64 64
 }
65 65
 
66 66
 
@@ -72,82 +72,82 @@  discard block
 block discarded – undo
72 72
 
73 73
 abstract class ModeleNumRefCommandes
74 74
 {
75
-	/**
76
-	 * @var string Error code (or message)
77
-	 */
78
-	public $error='';
79
-
80
-	/**
81
-	 *	Return if a module can be used or not
82
-	 *
83
-	 *	@return		boolean     true if module can be used
84
-	 */
85
-	function isEnabled()
86
-	{
87
-		return true;
88
-	}
89
-
90
-	/**
91
-	 *	Renvoie la description par defaut du modele de numerotation
92
-	 *
93
-	 *	@return     string      Texte descripif
94
-	 */
95
-	function info()
96
-	{
97
-		global $langs;
98
-		$langs->load("orders");
99
-		return $langs->trans("NoDescription");
100
-	}
101
-
102
-	/**
103
-	 *	Renvoie un exemple de numerotation
104
-	 *
105
-	 *	@return     string      Example
106
-	 */
107
-	function getExample()
108
-	{
109
-		global $langs;
110
-		$langs->load("orders");
111
-		return $langs->trans("NoExample");
112
-	}
113
-
114
-	/**
115
-	 *	Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
116
-	 *
117
-	 *	@return     boolean     false si conflit, true si ok
118
-	 */
119
-	function canBeActivated()
120
-	{
121
-		return true;
122
-	}
123
-
124
-	/**
125
-	 *	Renvoie prochaine valeur attribuee
126
-	 *
127
-	 *	@param	Societe		$objsoc     Object thirdparty
128
-	 *	@param	Object		$object		Object we need next value for
129
-	 *	@return	string      Valeur
130
-	 */
131
-	function getNextValue($objsoc,$object)
132
-	{
133
-		global $langs;
134
-		return $langs->trans("NotAvailable");
135
-	}
136
-
137
-	/**
138
-	 *	Renvoie version du module numerotation
139
-	 *
140
-	 *	@return     string      Valeur
141
-	 */
142
-	function getVersion()
143
-	{
144
-		global $langs;
145
-		$langs->load("admin");
146
-
147
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
-		if ($this->version == 'dolibarr') return DOL_VERSION;
150
-		if ($this->version) return $this->version;
151
-		return $langs->trans("NotAvailable");
152
-	}
75
+    /**
76
+     * @var string Error code (or message)
77
+     */
78
+    public $error='';
79
+
80
+    /**
81
+     *	Return if a module can be used or not
82
+     *
83
+     *	@return		boolean     true if module can be used
84
+     */
85
+    function isEnabled()
86
+    {
87
+        return true;
88
+    }
89
+
90
+    /**
91
+     *	Renvoie la description par defaut du modele de numerotation
92
+     *
93
+     *	@return     string      Texte descripif
94
+     */
95
+    function info()
96
+    {
97
+        global $langs;
98
+        $langs->load("orders");
99
+        return $langs->trans("NoDescription");
100
+    }
101
+
102
+    /**
103
+     *	Renvoie un exemple de numerotation
104
+     *
105
+     *	@return     string      Example
106
+     */
107
+    function getExample()
108
+    {
109
+        global $langs;
110
+        $langs->load("orders");
111
+        return $langs->trans("NoExample");
112
+    }
113
+
114
+    /**
115
+     *	Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
116
+     *
117
+     *	@return     boolean     false si conflit, true si ok
118
+     */
119
+    function canBeActivated()
120
+    {
121
+        return true;
122
+    }
123
+
124
+    /**
125
+     *	Renvoie prochaine valeur attribuee
126
+     *
127
+     *	@param	Societe		$objsoc     Object thirdparty
128
+     *	@param	Object		$object		Object we need next value for
129
+     *	@return	string      Valeur
130
+     */
131
+    function getNextValue($objsoc,$object)
132
+    {
133
+        global $langs;
134
+        return $langs->trans("NotAvailable");
135
+    }
136
+
137
+    /**
138
+     *	Renvoie version du module numerotation
139
+     *
140
+     *	@return     string      Valeur
141
+     */
142
+    function getVersion()
143
+    {
144
+        global $langs;
145
+        $langs->load("admin");
146
+
147
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
+        if ($this->version == 'dolibarr') return DOL_VERSION;
150
+        if ($this->version) return $this->version;
151
+        return $langs->trans("NotAvailable");
152
+    }
153 153
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
33
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';	// required for use by classes that inherit
33
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
34 34
 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
35 35
 
36 36
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of templates
50 50
 	 */
51
-	static function liste_modeles($db, $maxfilenamelength=0)
51
+	static function liste_modeles($db, $maxfilenamelength = 0)
52 52
 	{
53 53
         // phpcs:enable
54 54
 		global $conf;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @var string Error code (or message)
77 77
 	 */
78
-	public $error='';
78
+	public $error = '';
79 79
 
80 80
 	/**
81 81
 	 *	Return if a module can be used or not
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 *	@param	Object		$object		Object we need next value for
129 129
 	 *	@return	string      Valeur
130 130
 	 */
131
-	function getNextValue($objsoc,$object)
131
+	function getNextValue($objsoc, $object)
132 132
 	{
133 133
 		global $langs;
134 134
 		return $langs->trans("NotAvailable");
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/mod_commande_saphir.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_commande_saphir extends ModeleNumRefCommandes
35 35
 {
36
-	/**
36
+    /**
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
41 41
 
42
-	/**
43
-	 * @var string Error message
44
-	 */
45
-	public $error = '';
42
+    /**
43
+     * @var string Error message
44
+     */
45
+    public $error = '';
46 46
 
47
-	/**
48
-	 * @var string nom
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Saphir';
47
+    /**
48
+     * @var string nom
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Saphir';
53 53
 
54
-	/**
55
-	 * @var string name
56
-	 */
57
-	public $name='Saphir';
54
+    /**
55
+     * @var string name
56
+     */
57
+    public $name='Saphir';
58 58
 
59 59
 
60 60
     /**
@@ -62,39 +62,39 @@  discard block
 block discarded – undo
62 62
      *
63 63
      *  @return     string      Texte descripif
64 64
      */
65
-	function info()
65
+    function info()
66 66
     {
67
-    	global $conf, $langs;
67
+        global $conf, $langs;
68 68
 
69
-		$langs->load("bills");
69
+        $langs->load("bills");
70 70
 
71
-		$form = new Form($this->db);
71
+        $form = new Form($this->db);
72 72
 
73
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
73
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
77
+        $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
+        $texte.= '<table class="nobordernopadding" width="100%">';
79 79
 
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
80
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
+        $tooltip.=$langs->trans("GenericMaskCodes2");
82
+        $tooltip.=$langs->trans("GenericMaskCodes3");
83
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
+        $tooltip.=$langs->trans("GenericMaskCodes5");
85 85
 
86
-		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
86
+        // Parametrage du prefix
87
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+        $texte.= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+        $texte.= '</table>';
95
+        $texte.= '</form>';
96 96
 
97
-		return $texte;
97
+        return $texte;
98 98
     }
99 99
 
100 100
     /**
@@ -104,60 +104,60 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-     	global $conf,$langs,$mysoc;
108
-
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$old_code_type=$mysoc->typent_code;
111
-    	$mysoc->code_client='CCCCCCCCCC';
112
-    	$mysoc->typent_code='TTTTTTTTTT';
113
-     	$numExample = $this->getNextValue($mysoc,'');
114
-		$mysoc->code_client=$old_code_client;
115
-		$mysoc->typent_code=$old_code_type;
116
-
117
-		if (! $numExample)
118
-		{
119
-			$numExample = $langs->trans('NotConfigured');
120
-		}
121
-		return $numExample;
107
+            global $conf,$langs,$mysoc;
108
+
109
+        $old_code_client=$mysoc->code_client;
110
+        $old_code_type=$mysoc->typent_code;
111
+        $mysoc->code_client='CCCCCCCCCC';
112
+        $mysoc->typent_code='TTTTTTTTTT';
113
+            $numExample = $this->getNextValue($mysoc,'');
114
+        $mysoc->code_client=$old_code_client;
115
+        $mysoc->typent_code=$old_code_type;
116
+
117
+        if (! $numExample)
118
+        {
119
+            $numExample = $langs->trans('NotConfigured');
120
+        }
121
+        return $numExample;
122 122
     }
123 123
 
124
-	/**
125
-	 * 	Return next free value
126
-	 *
127
-	 *  @param	Societe		$objsoc     Object thirdparty
128
-	 *  @param  Object		$object		Object we need next value for
129
-	 *  @return string      			Value if KO, <0 if KO
130
-	 */
124
+    /**
125
+     * 	Return next free value
126
+     *
127
+     *  @param	Societe		$objsoc     Object thirdparty
128
+     *  @param  Object		$object		Object we need next value for
129
+     *  @return string      			Value if KO, <0 if KO
130
+     */
131 131
     function getNextValue($objsoc,$object)
132 132
     {
133
-		global $db,$conf;
133
+        global $db,$conf;
134 134
 
135
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
135
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
136 136
 
137
-		// We get cursor rule
138
-		$mask=$conf->global->COMMANDE_SAPHIR_MASK;
137
+        // We get cursor rule
138
+        $mask=$conf->global->COMMANDE_SAPHIR_MASK;
139 139
 
140
-		if (! $mask)
141
-		{
142
-			$this->error='NotConfigured';
143
-			return 0;
144
-		}
140
+        if (! $mask)
141
+        {
142
+            $this->error='NotConfigured';
143
+            return 0;
144
+        }
145 145
 
146
-		$date = ($object->date_commande ? $object->date_commande : $object->date);
146
+        $date = ($object->date_commande ? $object->date_commande : $object->date);
147 147
 
148
-		$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date);
148
+        $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date);
149 149
 
150
-		return  $numFinal;
151
-	}
150
+        return  $numFinal;
151
+    }
152 152
 
153 153
 
154 154
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
155
-	/**
156
-	 *  Return next free value
157
-	 *
158
-	 *  @param	Societe		$objsoc     Object third party
159
-	 *  @param	string		$objforref	Object for number to search
160
-	 *  @return string      			Next free value
155
+    /**
156
+     *  Return next free value
157
+     *
158
+     *  @param	Societe		$objsoc     Object third party
159
+     *  @param	string		$objforref	Object for number to search
160
+     *  @return string      			Next free value
161 161
      */
162 162
     function commande_get_num($objsoc,$objforref)
163 163
     {
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * \brief      Fichier contenant la classe du modele de numerotation de reference de commande Saphir
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
29 29
 
30 30
 
31 31
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
41 41
 
42 42
 	/**
43 43
 	 * @var string Error message
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Saphir';
52
+	public $nom = 'Saphir';
53 53
 
54 54
 	/**
55 55
 	 * @var string name
56 56
 	 */
57
-	public $name='Saphir';
57
+	public $name = 'Saphir';
58 58
 
59 59
 
60 60
     /**
@@ -71,28 +71,28 @@  discard block
 block discarded – undo
71 71
 		$form = new Form($this->db);
72 72
 
73 73
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
79
-
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
74
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
77
+		$texte .= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
78
+		$texte .= '<table class="nobordernopadding" width="100%">';
79
+
80
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
81
+		$tooltip .= $langs->trans("GenericMaskCodes2");
82
+		$tooltip .= $langs->trans("GenericMaskCodes3");
83
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
84
+		$tooltip .= $langs->trans("GenericMaskCodes5");
85 85
 
86 86
 		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
87
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+		$texte .= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+		$texte .= '</table>';
95
+		$texte .= '</form>';
96 96
 
97 97
 		return $texte;
98 98
     }
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-     	global $conf,$langs,$mysoc;
107
+     	global $conf, $langs, $mysoc;
108 108
 
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$old_code_type=$mysoc->typent_code;
111
-    	$mysoc->code_client='CCCCCCCCCC';
112
-    	$mysoc->typent_code='TTTTTTTTTT';
113
-     	$numExample = $this->getNextValue($mysoc,'');
114
-		$mysoc->code_client=$old_code_client;
115
-		$mysoc->typent_code=$old_code_type;
109
+    	$old_code_client = $mysoc->code_client;
110
+    	$old_code_type = $mysoc->typent_code;
111
+    	$mysoc->code_client = 'CCCCCCCCCC';
112
+    	$mysoc->typent_code = 'TTTTTTTTTT';
113
+     	$numExample = $this->getNextValue($mysoc, '');
114
+		$mysoc->code_client = $old_code_client;
115
+		$mysoc->typent_code = $old_code_type;
116 116
 
117
-		if (! $numExample)
117
+		if (!$numExample)
118 118
 		{
119 119
 			$numExample = $langs->trans('NotConfigured');
120 120
 		}
@@ -128,24 +128,24 @@  discard block
 block discarded – undo
128 128
 	 *  @param  Object		$object		Object we need next value for
129 129
 	 *  @return string      			Value if KO, <0 if KO
130 130
 	 */
131
-    function getNextValue($objsoc,$object)
131
+    function getNextValue($objsoc, $object)
132 132
     {
133
-		global $db,$conf;
133
+		global $db, $conf;
134 134
 
135
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
135
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
136 136
 
137 137
 		// We get cursor rule
138
-		$mask=$conf->global->COMMANDE_SAPHIR_MASK;
138
+		$mask = $conf->global->COMMANDE_SAPHIR_MASK;
139 139
 
140
-		if (! $mask)
140
+		if (!$mask)
141 141
 		{
142
-			$this->error='NotConfigured';
142
+			$this->error = 'NotConfigured';
143 143
 			return 0;
144 144
 		}
145 145
 
146 146
 		$date = ($object->date_commande ? $object->date_commande : $object->date);
147 147
 
148
-		$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date);
148
+		$numFinal = get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date);
149 149
 
150 150
 		return  $numFinal;
151 151
 	}
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 *  @param	string		$objforref	Object for number to search
160 160
 	 *  @return string      			Next free value
161 161
      */
162
-    function commande_get_num($objsoc,$objforref)
162
+    function commande_get_num($objsoc, $objforref)
163 163
     {
164 164
         // phpcs:enable
165
-        return $this->getNextValue($objsoc,$objforref);
165
+        return $this->getNextValue($objsoc, $objforref);
166 166
     }
167 167
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/mod_commande_marbre.php 3 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class mod_commande_marbre extends ModeleNumRefCommandes
31 31
 {
32
-	/**
32
+    /**
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
36
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37 37
 
38
-	public $prefix='CO';
38
+    public $prefix='CO';
39 39
 
40
-	/**
41
-	 * @var string Error code (or message)
42
-	 */
43
-	public $error='';
40
+    /**
41
+     * @var string Error code (or message)
42
+     */
43
+    public $error='';
44 44
 
45
-	/**
46
-	 * @var string
47
-	 * @deprecated
48
-	 * @see name
49
-	 */
50
-	public $nom='Marbre';
45
+    /**
46
+     * @var string
47
+     * @deprecated
48
+     * @see name
49
+     */
50
+    public $nom='Marbre';
51 51
 
52
-	/**
53
-	 * @var string name
54
-	 */
55
-	public $name='Marbre';
52
+    /**
53
+     * @var string name
54
+     */
55
+    public $name='Marbre';
56 56
 
57 57
 
58 58
     /**
@@ -62,110 +62,110 @@  discard block
 block discarded – undo
62 62
      */
63 63
     function info()
64 64
     {
65
-    	global $langs;
66
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
65
+        global $langs;
66
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67 67
     }
68 68
 
69 69
 
70
-	/**
71
-	 *  Renvoi un exemple de numerotation
72
-	 *
73
-	 *  @return     string      Example
74
-	 */
75
-	function getExample()
76
-	{
77
-		return $this->prefix."0501-0001";
78
-	}
79
-
80
-
81
-	/**
82
-	 *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
83
-	 *  de conflits qui empechera cette numerotation de fonctionner.
84
-	 *
85
-	 *  @return     boolean     false si conflit, true si ok
86
-	 */
87
-	function canBeActivated()
88
-	{
89
-		global $conf,$langs,$db;
90
-
91
-		$coyymm=''; $max='';
92
-
93
-		$posindice=8;
94
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
95
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
96
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
-		$sql.= " AND entity = ".$conf->entity;
98
-
99
-		$resql=$db->query($sql);
100
-		if ($resql)
101
-		{
102
-			$row = $db->fetch_row($resql);
103
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
104
-		}
105
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106
-		{
107
-			$langs->load("errors");
108
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
109
-			return false;
110
-		}
111
-
112
-		return true;
113
-	}
114
-
115
-	/**
116
-	 * 	Return next free value
117
-	 *
118
-	 *  @param	Societe		$objsoc     Object thirdparty
119
-	 *  @param  Object		$object		Object we need next value for
120
-	 *  @return string      			Value if KO, <0 if KO
121
-	 */
122
-	function getNextValue($objsoc,$object)
123
-	{
124
-		global $db,$conf;
125
-
126
-		// D'abord on recupere la valeur max
127
-		$posindice=8;
128
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
130
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
-		$sql.= " AND entity = ".$conf->entity;
132
-
133
-		$resql=$db->query($sql);
134
-		if ($resql)
135
-		{
136
-			$obj = $db->fetch_object($resql);
137
-			if ($obj) $max = intval($obj->max);
138
-			else $max=0;
139
-		}
140
-		else
141
-		{
142
-			dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG);
143
-			return -1;
144
-		}
145
-
146
-		//$date=time();
147
-		$date=$object->date;
148
-		$yymm = strftime("%y%m",$date);
149
-
150
-    	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
151
-    	else $num = sprintf("%04s", $max+1);
152
-
153
-		dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154
-		return $this->prefix.$yymm."-".$num;
155
-	}
70
+    /**
71
+     *  Renvoi un exemple de numerotation
72
+     *
73
+     *  @return     string      Example
74
+     */
75
+    function getExample()
76
+    {
77
+        return $this->prefix."0501-0001";
78
+    }
79
+
80
+
81
+    /**
82
+     *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
83
+     *  de conflits qui empechera cette numerotation de fonctionner.
84
+     *
85
+     *  @return     boolean     false si conflit, true si ok
86
+     */
87
+    function canBeActivated()
88
+    {
89
+        global $conf,$langs,$db;
90
+
91
+        $coyymm=''; $max='';
92
+
93
+        $posindice=8;
94
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
95
+        $sql.= " FROM ".MAIN_DB_PREFIX."commande";
96
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
+        $sql.= " AND entity = ".$conf->entity;
98
+
99
+        $resql=$db->query($sql);
100
+        if ($resql)
101
+        {
102
+            $row = $db->fetch_row($resql);
103
+            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
104
+        }
105
+        if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106
+        {
107
+            $langs->load("errors");
108
+            $this->error=$langs->trans('ErrorNumRefModel', $max);
109
+            return false;
110
+        }
111
+
112
+        return true;
113
+    }
114
+
115
+    /**
116
+     * 	Return next free value
117
+     *
118
+     *  @param	Societe		$objsoc     Object thirdparty
119
+     *  @param  Object		$object		Object we need next value for
120
+     *  @return string      			Value if KO, <0 if KO
121
+     */
122
+    function getNextValue($objsoc,$object)
123
+    {
124
+        global $db,$conf;
125
+
126
+        // D'abord on recupere la valeur max
127
+        $posindice=8;
128
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
+        $sql.= " FROM ".MAIN_DB_PREFIX."commande";
130
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
+        $sql.= " AND entity = ".$conf->entity;
132
+
133
+        $resql=$db->query($sql);
134
+        if ($resql)
135
+        {
136
+            $obj = $db->fetch_object($resql);
137
+            if ($obj) $max = intval($obj->max);
138
+            else $max=0;
139
+        }
140
+        else
141
+        {
142
+            dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG);
143
+            return -1;
144
+        }
145
+
146
+        //$date=time();
147
+        $date=$object->date;
148
+        $yymm = strftime("%y%m",$date);
149
+
150
+        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
151
+        else $num = sprintf("%04s", $max+1);
152
+
153
+        dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154
+        return $this->prefix.$yymm."-".$num;
155
+    }
156 156
 
157 157
 
158 158
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
159
-	/**
160
-	 *  Return next free value
161
-	 *
162
-	 *  @param	Societe		$objsoc     Object third party
163
-	 * 	@param	string		$objforref	Object for number to search
164
-	 *  @return string      			Next free value
165
-	 */
166
-	function commande_get_num($objsoc,$objforref)
167
-	{
159
+    /**
160
+     *  Return next free value
161
+     *
162
+     *  @param	Societe		$objsoc     Object third party
163
+     * 	@param	string		$objforref	Object for number to search
164
+     *  @return string      			Next free value
165
+     */
166
+    function commande_get_num($objsoc,$objforref)
167
+    {
168 168
         // phpcs:enable
169
-		return $this->getNextValue($objsoc,$objforref);
170
-	}
169
+        return $this->getNextValue($objsoc,$objforref);
170
+    }
171 171
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *  \ingroup    commande
23 23
  *  \brief      File of class to manage customer order numbering rules Marbre
24 24
  */
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
26 26
 
27 27
 /**
28 28
  *	Class to manage customer order numbering rules Marbre
@@ -33,26 +33,26 @@  discard block
 block discarded – undo
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
36
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
37 37
 
38
-	public $prefix='CO';
38
+	public $prefix = 'CO';
39 39
 
40 40
 	/**
41 41
 	 * @var string Error code (or message)
42 42
 	 */
43
-	public $error='';
43
+	public $error = '';
44 44
 
45 45
 	/**
46 46
 	 * @var string
47 47
 	 * @deprecated
48 48
 	 * @see name
49 49
 	 */
50
-	public $nom='Marbre';
50
+	public $nom = 'Marbre';
51 51
 
52 52
 	/**
53 53
 	 * @var string name
54 54
 	 */
55
-	public $name='Marbre';
55
+	public $name = 'Marbre';
56 56
 
57 57
 
58 58
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     function info()
64 64
     {
65 65
     	global $langs;
66
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
66
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
67 67
     }
68 68
 
69 69
 
@@ -86,26 +86,26 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	function canBeActivated()
88 88
 	{
89
-		global $conf,$langs,$db;
89
+		global $conf, $langs, $db;
90 90
 
91
-		$coyymm=''; $max='';
91
+		$coyymm = ''; $max = '';
92 92
 
93
-		$posindice=8;
93
+		$posindice = 8;
94 94
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
95
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
96
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
-		$sql.= " AND entity = ".$conf->entity;
95
+		$sql .= " FROM ".MAIN_DB_PREFIX."commande";
96
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
+		$sql .= " AND entity = ".$conf->entity;
98 98
 
99
-		$resql=$db->query($sql);
99
+		$resql = $db->query($sql);
100 100
 		if ($resql)
101 101
 		{
102 102
 			$row = $db->fetch_row($resql);
103
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
103
+			if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
104 104
 		}
105
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
105
+		if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
106 106
 		{
107 107
 			$langs->load("errors");
108
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
108
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
109 109
 			return false;
110 110
 		}
111 111
 
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
 	 *  @param  Object		$object		Object we need next value for
120 120
 	 *  @return string      			Value if KO, <0 if KO
121 121
 	 */
122
-	function getNextValue($objsoc,$object)
122
+	function getNextValue($objsoc, $object)
123 123
 	{
124
-		global $db,$conf;
124
+		global $db, $conf;
125 125
 
126 126
 		// D'abord on recupere la valeur max
127
-		$posindice=8;
127
+		$posindice = 8;
128 128
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
-		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
130
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
-		$sql.= " AND entity = ".$conf->entity;
129
+		$sql .= " FROM ".MAIN_DB_PREFIX."commande";
130
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
131
+		$sql .= " AND entity = ".$conf->entity;
132 132
 
133
-		$resql=$db->query($sql);
133
+		$resql = $db->query($sql);
134 134
 		if ($resql)
135 135
 		{
136 136
 			$obj = $db->fetch_object($resql);
137 137
 			if ($obj) $max = intval($obj->max);
138
-			else $max=0;
138
+			else $max = 0;
139 139
 		}
140 140
 		else
141 141
 		{
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 
146 146
 		//$date=time();
147
-		$date=$object->date;
148
-		$yymm = strftime("%y%m",$date);
147
+		$date = $object->date;
148
+		$yymm = strftime("%y%m", $date);
149 149
 
150
-    	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
151
-    	else $num = sprintf("%04s", $max+1);
150
+    	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
151
+    	else $num = sprintf("%04s", $max + 1);
152 152
 
153 153
 		dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154 154
 		return $this->prefix.$yymm."-".$num;
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 * 	@param	string		$objforref	Object for number to search
164 164
 	 *  @return string      			Next free value
165 165
 	 */
166
-	function commande_get_num($objsoc,$objforref)
166
+	function commande_get_num($objsoc, $objforref)
167 167
 	{
168 168
         // phpcs:enable
169
-		return $this->getNextValue($objsoc,$objforref);
169
+		return $this->getNextValue($objsoc, $objforref);
170 170
 	}
171 171
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -134,10 +134,12 @@  discard block
 block discarded – undo
134 134
 		if ($resql)
135 135
 		{
136 136
 			$obj = $db->fetch_object($resql);
137
-			if ($obj) $max = intval($obj->max);
138
-			else $max=0;
139
-		}
140
-		else
137
+			if ($obj) {
138
+			    $max = intval($obj->max);
139
+			} else {
140
+			    $max=0;
141
+			}
142
+		} else
141 143
 		{
142 144
 			dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG);
143 145
 			return -1;
@@ -147,8 +149,13 @@  discard block
 block discarded – undo
147 149
 		$date=$object->date;
148 150
 		$yymm = strftime("%y%m",$date);
149 151
 
150
-    	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
151
-    	else $num = sprintf("%04s", $max+1);
152
+    	if ($max >= (pow(10, 4) - 1)) {
153
+    	    $num=$max+1;
154
+    	}
155
+    	// If counter > 9999, we do not format on 4 chars, we take number as it is
156
+    	else {
157
+    	    $num = sprintf("%04s", $max+1);
158
+    	}
152 159
 
153 160
 		dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
154 161
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modTakePos.class.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -32,131 +32,131 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class modTakePos extends DolibarrModules
34 34
 {
35
-	/**
36
-	 * Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 * @param DoliDB $db Database handler
39
-	 */
40
-	public function __construct($db)
41
-	{
35
+    /**
36
+     * Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     * @param DoliDB $db Database handler
39
+     */
40
+    public function __construct($db)
41
+    {
42 42
         global $langs,$conf;
43 43
 
44 44
         $this->db = $db;
45 45
 
46
-		// Id for module (must be unique).
47
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
-		$this->numero = 50150;
49
-		// Key text used to identify module (for permissions, menus, etc...)
50
-		$this->rights_class = 'takepos';
51
-
52
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
53
-		// It is used to group modules by family in module setup page
54
-		$this->family = "portal";
55
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
56
-		$this->module_position = '60';
57
-		// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
58
-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59
-
60
-		// Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module).
61
-		$this->name = preg_replace('/^mod/i','',get_class($this));
62
-		// Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module).
63
-		$this->description = "Point of sales module (Touch Screen POS)";
64
-		// Used only if file README.md and README-LL.md not found.
65
-		$this->descriptionlong = "Point Of Sales (compliant with touch screen)";
66
-
67
-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
68
-		$this->version = 'experimental';
69
-		// Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase)
70
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71
-		// Name of image file used for this module.
72
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73
-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
-		$this->picto='list';
75
-
76
-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77
-		// for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
78
-		// for specific path of parts (eg: /takepos/core/modules/barcode)
79
-		// for specific css file (eg: /takepos/css/takepos.css.php)
80
-		$this->module_parts = array(
81
-		                        	'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
82
-									'login' => 0,                                    	// Set this to 1 if module has its own login method file (core/login)
83
-									'substitutions' => 1,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
84
-									'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
85
-									'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
86
-		                        	'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
87
-									'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
-									'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
89
-									'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') 	// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
90
-		                        );
91
-
92
-		// Data directories to create when module is enabled.
93
-		// Example: this->dirs = array("/takepos/temp","/takepos/subdir");
94
-		$this->dirs = array();
95
-
96
-		// Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module.
97
-		$this->config_page_url = array("setup.php@takepos");
98
-
99
-		// Dependencies
100
-		$this->hidden = false;			// A condition to hide module
101
-		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog');			// List of module class names as string that must be enabled if this module is enabled
102
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
103
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
104
-		$this->langfiles = array("cashdesk");
105
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
106
-		$this->need_dolibarr_version = array(4,0);	// Minimum version of Dolibarr required by module
107
-		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
109
-		//$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
110
-		//$this->always_enabled = true;								// If true, can't be disabled
111
-
112
-		// Constants
113
-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
114
-		// Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
115
-		//                             1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
116
-		// );
117
-		$this->const = array(
118
-			//1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
119
-		);
120
-
121
-
122
-		if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
123
-		{
124
-			$conf->takepos=new stdClass();
125
-			$conf->takepos->enabled=0;
126
-		}
127
-
128
-
129
-		// Array to add new pages in new tabs
46
+        // Id for module (must be unique).
47
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
48
+        $this->numero = 50150;
49
+        // Key text used to identify module (for permissions, menus, etc...)
50
+        $this->rights_class = 'takepos';
51
+
52
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
53
+        // It is used to group modules by family in module setup page
54
+        $this->family = "portal";
55
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
56
+        $this->module_position = '60';
57
+        // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
58
+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59
+
60
+        // Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module).
61
+        $this->name = preg_replace('/^mod/i','',get_class($this));
62
+        // Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module).
63
+        $this->description = "Point of sales module (Touch Screen POS)";
64
+        // Used only if file README.md and README-LL.md not found.
65
+        $this->descriptionlong = "Point Of Sales (compliant with touch screen)";
66
+
67
+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
68
+        $this->version = 'experimental';
69
+        // Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase)
70
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71
+        // Name of image file used for this module.
72
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73
+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
+        $this->picto='list';
75
+
76
+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77
+        // for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
78
+        // for specific path of parts (eg: /takepos/core/modules/barcode)
79
+        // for specific css file (eg: /takepos/css/takepos.css.php)
80
+        $this->module_parts = array(
81
+                                    'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
82
+                                    'login' => 0,                                    	// Set this to 1 if module has its own login method file (core/login)
83
+                                    'substitutions' => 1,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
84
+                                    'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
85
+                                    'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
86
+                                    'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
87
+                                    'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
+                                    'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
89
+                                    'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') 	// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
90
+                                );
91
+
92
+        // Data directories to create when module is enabled.
93
+        // Example: this->dirs = array("/takepos/temp","/takepos/subdir");
94
+        $this->dirs = array();
95
+
96
+        // Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module.
97
+        $this->config_page_url = array("setup.php@takepos");
98
+
99
+        // Dependencies
100
+        $this->hidden = false;			// A condition to hide module
101
+        $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog');			// List of module class names as string that must be enabled if this module is enabled
102
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
103
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
104
+        $this->langfiles = array("cashdesk");
105
+        $this->phpmin = array(5,4);					// Minimum version of PHP required by module
106
+        $this->need_dolibarr_version = array(4,0);	// Minimum version of Dolibarr required by module
107
+        $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
+        $this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
109
+        //$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
110
+        //$this->always_enabled = true;								// If true, can't be disabled
111
+
112
+        // Constants
113
+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
114
+        // Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
115
+        //                             1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
116
+        // );
117
+        $this->const = array(
118
+            //1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
119
+        );
120
+
121
+
122
+        if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
123
+        {
124
+            $conf->takepos=new stdClass();
125
+            $conf->takepos->enabled=0;
126
+        }
127
+
128
+
129
+        // Array to add new pages in new tabs
130 130
         $this->tabs = array();
131
-		// Example:
132
-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
131
+        // Example:
132
+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
133 133
         // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
134 134
         // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname
135 135
         //
136 136
         // Where objecttype can be
137
-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
138
-		// 'contact'          to add a tab in contact view
139
-		// 'contract'         to add a tab in contract view
140
-		// 'group'            to add a tab in group view
141
-		// 'intervention'     to add a tab in intervention view
142
-		// 'invoice'          to add a tab in customer invoice view
143
-		// 'invoice_supplier' to add a tab in supplier invoice view
144
-		// 'member'           to add a tab in fundation member view
145
-		// 'opensurveypoll'	  to add a tab in opensurvey poll view
146
-		// 'order'            to add a tab in customer order view
147
-		// 'order_supplier'   to add a tab in supplier order view
148
-		// 'payment'		  to add a tab in payment view
149
-		// 'payment_supplier' to add a tab in supplier payment view
150
-		// 'product'          to add a tab in product view
151
-		// 'propal'           to add a tab in propal view
152
-		// 'project'          to add a tab in project view
153
-		// 'stock'            to add a tab in stock view
154
-		// 'thirdparty'       to add a tab in third party view
155
-		// 'user'             to add a tab in user view
137
+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
138
+        // 'contact'          to add a tab in contact view
139
+        // 'contract'         to add a tab in contract view
140
+        // 'group'            to add a tab in group view
141
+        // 'intervention'     to add a tab in intervention view
142
+        // 'invoice'          to add a tab in customer invoice view
143
+        // 'invoice_supplier' to add a tab in supplier invoice view
144
+        // 'member'           to add a tab in fundation member view
145
+        // 'opensurveypoll'	  to add a tab in opensurvey poll view
146
+        // 'order'            to add a tab in customer order view
147
+        // 'order_supplier'   to add a tab in supplier order view
148
+        // 'payment'		  to add a tab in payment view
149
+        // 'payment_supplier' to add a tab in supplier payment view
150
+        // 'product'          to add a tab in product view
151
+        // 'propal'           to add a tab in propal view
152
+        // 'project'          to add a tab in project view
153
+        // 'stock'            to add a tab in stock view
154
+        // 'thirdparty'       to add a tab in third party view
155
+        // 'user'             to add a tab in user view
156 156
 
157 157
 
158 158
         // Dictionaries
159
-		$this->dictionaries=array();
159
+        $this->dictionaries=array();
160 160
         /* Example:
161 161
         $this->dictionaries=array(
162 162
             'langs'=>'mylangfile@takepos',
@@ -174,60 +174,60 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
         // Boxes/Widgets
177
-		// Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget.
177
+        // Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget.
178 178
         $this->boxes = array(
179
-        	//0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'),
180
-        	//1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'),
181
-        	//2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos')
179
+            //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'),
180
+            //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'),
181
+            //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos')
182 182
         );
183 183
 
184 184
 
185
-		// Cronjobs (List of cron jobs entries to add when module is enabled)
186
-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
187
-		$this->cronjobs = array(
188
-			//0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
189
-		);
190
-		// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
191
-		//                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
192
-		// );
185
+        // Cronjobs (List of cron jobs entries to add when module is enabled)
186
+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
187
+        $this->cronjobs = array(
188
+            //0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
189
+        );
190
+        // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
191
+        //                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
192
+        // );
193 193
 
194 194
 
195
-		// Permissions
196
-		$this->rights = array();		// Permission array used by this module
195
+        // Permissions
196
+        $this->rights = array();		// Permission array used by this module
197 197
 
198
-		$r=0;
198
+        $r=0;
199 199
 
200
-		$r++;
201
-		$this->rights[$r][0] = 50151;
202
-		$this->rights[$r][1] = 'Use point of sale';
203
-		$this->rights[$r][2] = 'a';
204
-		$this->rights[$r][3] = 0;
205
-		$this->rights[$r][4] = 'use';
200
+        $r++;
201
+        $this->rights[$r][0] = 50151;
202
+        $this->rights[$r][1] = 'Use point of sale';
203
+        $this->rights[$r][2] = 'a';
204
+        $this->rights[$r][3] = 0;
205
+        $this->rights[$r][4] = 'use';
206 206
 
207 207
 
208
-		// Main menu entries
209
-		$this->menu = array();			// List of menus to add
210
-		$r=0;
208
+        // Main menu entries
209
+        $this->menu = array();			// List of menus to add
210
+        $r=0;
211 211
 
212
-		// Add here entries to declare new menus
212
+        // Add here entries to declare new menus
213 213
 
214
-		/* BEGIN MODULEBUILDER TOPMENU */
215
-		$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
-								'type'=>'top',			                // This is a Top menu entry
217
-								'titre'=>'PointOfSaleShort',
218
-								'mainmenu'=>'takepos',
219
-								'leftmenu'=>'',
220
-								'url'=>'/takepos/takepos.php',
221
-								'langs'=>'cashdesk',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
-								'position'=>1000+$r,
223
-								'enabled'=>'$conf->takepos->enabled',	// Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
-								'perms'=>'1',			                // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
225
-								'target'=>'takepos',
226
-								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
214
+        /* BEGIN MODULEBUILDER TOPMENU */
215
+        $this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
+                                'type'=>'top',			                // This is a Top menu entry
217
+                                'titre'=>'PointOfSaleShort',
218
+                                'mainmenu'=>'takepos',
219
+                                'leftmenu'=>'',
220
+                                'url'=>'/takepos/takepos.php',
221
+                                'langs'=>'cashdesk',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
+                                'position'=>1000+$r,
223
+                                'enabled'=>'$conf->takepos->enabled',	// Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
+                                'perms'=>'1',			                // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
225
+                                'target'=>'takepos',
226
+                                'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
227 227
 
228
-		/* END MODULEBUILDER TOPMENU */
228
+        /* END MODULEBUILDER TOPMENU */
229 229
 
230
-		/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
230
+        /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
231 231
 		$this->menu[$r++]=array(	'fk_menu'=>'fk_mainmenu=takepos',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
232 232
 								'type'=>'left',			                // This is a Left menu entry
233 233
 								'titre'=>'List MyObject',
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 		END MODULEBUILDER LEFTMENU MYOBJECT */
256 256
 
257 257
 
258
-		// Exports
259
-		$r=1;
258
+        // Exports
259
+        $r=1;
260 260
 
261
-		/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
262
-		/*
261
+        /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
262
+        /*
263 263
 		$langs->load("cashdesk");
264 264
 		$this->export_code[$r]=$this->rights_class.'_'.$r;
265 265
 		$this->export_label[$r]='MyObjectLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
@@ -274,41 +274,41 @@  discard block
 block discarded – undo
274 274
 		$this->export_sql_end[$r] .=' WHERE 1 = 1';
275 275
 		$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
276 276
 		$r++; */
277
-		/* END MODULEBUILDER EXPORT MYOBJECT */
278
-	}
279
-
280
-	/**
281
-	 *	Function called when module is enabled.
282
-	 *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
283
-	 *	It also creates data directories
284
-	 *
277
+        /* END MODULEBUILDER EXPORT MYOBJECT */
278
+    }
279
+
280
+    /**
281
+     *	Function called when module is enabled.
282
+     *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
283
+     *	It also creates data directories
284
+     *
285
+     *	@param      string	$options    Options when enabling module ('', 'noboxes')
286
+     *	@return     int             	1 if OK, 0 if KO
287
+     */
288
+    public function init($options='')
289
+    {
290
+        $this->_load_tables('/takepos/sql/');
291
+
292
+        $sql = array();
293
+
294
+        // Remove permissions and default values
295
+        $this->remove($options);
296
+
297
+        return $this->_init($sql, $options);
298
+    }
299
+
300
+    /**
301
+     *	Function called when module is disabled.
302
+     *	Remove from database constants, boxes and permissions from Dolibarr database.
303
+     *	Data directories are not deleted
304
+     *
285 305
      *	@param      string	$options    Options when enabling module ('', 'noboxes')
286
-	 *	@return     int             	1 if OK, 0 if KO
287
-	 */
288
-	public function init($options='')
289
-	{
290
-		$this->_load_tables('/takepos/sql/');
291
-
292
-		$sql = array();
293
-
294
-		// Remove permissions and default values
295
-		$this->remove($options);
296
-
297
-		return $this->_init($sql, $options);
298
-	}
299
-
300
-	/**
301
-	 *	Function called when module is disabled.
302
-	 *	Remove from database constants, boxes and permissions from Dolibarr database.
303
-	 *	Data directories are not deleted
304
-	 *
305
-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')
306
-	 *	@return     int             	1 if OK, 0 if KO
307
-	 */
308
-	public function remove($options = '')
309
-	{
310
-		$sql = array();
311
-
312
-		return $this->_remove($sql, $options);
313
-	}
306
+     *	@return     int             	1 if OK, 0 if KO
307
+     */
308
+    public function remove($options = '')
309
+    {
310
+        $sql = array();
311
+
312
+        return $this->_remove($sql, $options);
313
+    }
314 314
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *  \ingroup    takepos
25 25
  *  \brief      Description and activation file for module TakePos
26 26
  */
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct($db)
41 41
 	{
42
-        global $langs,$conf;
42
+        global $langs, $conf;
43 43
 
44 44
         $this->db = $db;
45 45
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
59 59
 
60 60
 		// Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module).
61
-		$this->name = preg_replace('/^mod/i','',get_class($this));
61
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
62 62
 		// Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module).
63 63
 		$this->description = "Point of sales module (Touch Screen POS)";
64 64
 		// Used only if file README.md and README-LL.md not found.
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 		// Name of image file used for this module.
72 72
 		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73 73
 		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74
-		$this->picto='list';
74
+		$this->picto = 'list';
75 75
 
76 76
 		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
77 77
 		// for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
78 78
 		// for specific path of parts (eg: /takepos/core/modules/barcode)
79 79
 		// for specific css file (eg: /takepos/css/takepos.css.php)
80 80
 		$this->module_parts = array(
81
-		                        	'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
82
-									'login' => 0,                                    	// Set this to 1 if module has its own login method file (core/login)
83
-									'substitutions' => 1,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
84
-									'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
85
-									'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
86
-		                        	'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
87
-									'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
-									'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
81
+		                        	'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
82
+									'login' => 0, // Set this to 1 if module has its own login method file (core/login)
83
+									'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions)
84
+									'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
85
+									'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
86
+		                        	'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
87
+									'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
88
+									'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
89 89
 									'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') 	// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
90 90
 		                        );
91 91
 
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 		$this->config_page_url = array("setup.php@takepos");
98 98
 
99 99
 		// Dependencies
100
-		$this->hidden = false;			// A condition to hide module
101
-		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog');			// List of module class names as string that must be enabled if this module is enabled
102
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
103
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
100
+		$this->hidden = false; // A condition to hide module
101
+		$this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled
102
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
103
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
104 104
 		$this->langfiles = array("cashdesk");
105
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
106
-		$this->need_dolibarr_version = array(4,0);	// Minimum version of Dolibarr required by module
107
-		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw');                     // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
105
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
106
+		$this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module
107
+		$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
108
+		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
109 109
 		//$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
110 110
 		//$this->always_enabled = true;								// If true, can't be disabled
111 111
 
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 		);
120 120
 
121 121
 
122
-		if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
122
+		if (!isset($conf->takepos) || !isset($conf->takepos->enabled))
123 123
 		{
124
-			$conf->takepos=new stdClass();
125
-			$conf->takepos->enabled=0;
124
+			$conf->takepos = new stdClass();
125
+			$conf->takepos->enabled = 0;
126 126
 		}
127 127
 
128 128
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 
158 158
         // Dictionaries
159
-		$this->dictionaries=array();
159
+		$this->dictionaries = array();
160 160
         /* Example:
161 161
         $this->dictionaries=array(
162 162
             'langs'=>'mylangfile@takepos',
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 
194 194
 
195 195
 		// Permissions
196
-		$this->rights = array();		// Permission array used by this module
196
+		$this->rights = array(); // Permission array used by this module
197 197
 
198
-		$r=0;
198
+		$r = 0;
199 199
 
200 200
 		$r++;
201 201
 		$this->rights[$r][0] = 50151;
@@ -206,24 +206,24 @@  discard block
 block discarded – undo
206 206
 
207 207
 
208 208
 		// Main menu entries
209
-		$this->menu = array();			// List of menus to add
210
-		$r=0;
209
+		$this->menu = array(); // List of menus to add
210
+		$r = 0;
211 211
 
212 212
 		// Add here entries to declare new menus
213 213
 
214 214
 		/* BEGIN MODULEBUILDER TOPMENU */
215
-		$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
-								'type'=>'top',			                // This is a Top menu entry
215
+		$this->menu[$r++] = array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
+								'type'=>'top', // This is a Top menu entry
217 217
 								'titre'=>'PointOfSaleShort',
218 218
 								'mainmenu'=>'takepos',
219 219
 								'leftmenu'=>'',
220 220
 								'url'=>'/takepos/takepos.php',
221
-								'langs'=>'cashdesk',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
-								'position'=>1000+$r,
223
-								'enabled'=>'$conf->takepos->enabled',	// Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
-								'perms'=>'1',			                // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
221
+								'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
222
+								'position'=>1000 + $r,
223
+								'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
224
+								'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
225 225
 								'target'=>'takepos',
226
-								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
226
+								'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
227 227
 
228 228
 		/* END MODULEBUILDER TOPMENU */
229 229
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 
258 258
 		// Exports
259
-		$r=1;
259
+		$r = 1;
260 260
 
261 261
 		/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
262 262
 		/*
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      *	@param      string	$options    Options when enabling module ('', 'noboxes')
286 286
 	 *	@return     int             	1 if OK, 0 if KO
287 287
 	 */
288
-	public function init($options='')
288
+	public function init($options = '')
289 289
 	{
290 290
 		$this->_load_tables('/takepos/sql/');
291 291
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/doc/pdf_baleine.modules.php 3 patches
Indentation   +545 added lines, -545 removed lines patch added patch discarded remove patch
@@ -38,193 +38,193 @@  discard block
 block discarded – undo
38 38
 
39 39
 class pdf_baleine extends ModelePDFProjects
40 40
 {
41
-	/**
41
+    /**
42 42
      * @var DoliDb Database handler
43 43
      */
44 44
     public $db;
45 45
 
46
-	/**
46
+    /**
47 47
      * @var string model name
48 48
      */
49 49
     public $name;
50 50
 
51
-	/**
51
+    /**
52 52
      * @var string model description (short text)
53 53
      */
54 54
     public $description;
55 55
 
56
-	/**
56
+    /**
57 57
      * @var string document type
58 58
      */
59 59
     public $type;
60 60
 
61 61
     /**
62 62
      * @var array() Minimum version of PHP required by module.
63
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
63
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
64 64
      */
65
-	public $phpmin = array(5, 4);
65
+    public $phpmin = array(5, 4);
66 66
 
67
-	/**
67
+    /**
68 68
      * Dolibarr version of the loaded document
69 69
      * @public string
70 70
      */
71
-	public $version = 'dolibarr';
71
+    public $version = 'dolibarr';
72 72
 
73
-	/**
73
+    /**
74 74
      * @var int page_largeur
75 75
      */
76 76
     public $page_largeur;
77 77
 
78
-	/**
78
+    /**
79 79
      * @var int page_hauteur
80 80
      */
81 81
     public $page_hauteur;
82 82
 
83
-	/**
83
+    /**
84 84
      * @var array format
85 85
      */
86 86
     public $format;
87 87
 
88
-	/**
88
+    /**
89 89
      * @var int marge_gauche
90 90
      */
91
-	public $marge_gauche;
91
+    public $marge_gauche;
92 92
 
93
-	/**
93
+    /**
94 94
      * @var int marge_droite
95 95
      */
96
-	public $marge_droite;
96
+    public $marge_droite;
97 97
 
98
-	/**
98
+    /**
99 99
      * @var int marge_haute
100 100
      */
101
-	public $marge_haute;
101
+    public $marge_haute;
102 102
 
103
-	/**
103
+    /**
104 104
      * @var int marge_basse
105 105
      */
106
-	public $marge_basse;
107
-
108
-	/**
109
-	 * Issuer
110
-	 * @var Company object that emits
111
-	 */
112
-	public $emetteur;
113
-
114
-	/**
115
-	 *	Constructor
116
-	 *
117
-	 *  @param		DoliDB		$db      Database handler
118
-	 */
119
-	function __construct($db)
120
-	{
121
-		global $conf,$langs,$mysoc;
122
-
123
-		// Translations
124
-		$langs->loadLangs(array("main", "projects", "companies"));
125
-
126
-		$this->db = $db;
127
-		$this->name = "baleine";
128
-		$this->description = $langs->trans("DocumentModelBaleine");
129
-
130
-		// Dimension page pour format A4
131
-		$this->type = 'pdf';
132
-		$formatarray=pdf_getFormat();
133
-		$this->page_largeur = $formatarray['width'];
134
-		$this->page_hauteur = $formatarray['height'];
135
-		$this->format = array($this->page_largeur,$this->page_hauteur);
136
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
140
-
141
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
142
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
143
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
144
-
145
-		// Recupere emmetteur
146
-		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
-
149
-		// Defini position des colonnes
150
-		$this->posxref=$this->marge_gauche+1;
151
-		$this->posxlabel=$this->marge_gauche+25;
152
-		$this->posxworkload=$this->marge_gauche+120;
153
-		$this->posxprogress=$this->marge_gauche+140;
154
-		$this->posxdatestart=$this->marge_gauche+152;
155
-		$this->posxdateend=$this->marge_gauche+170;
156
-		if ($this->page_largeur < 210) // To work with US executive format
157
-		{
158
-			$this->posxref-=20;
159
-			$this->posxlabel-=20;
160
-			$this->posxworkload-=20;
161
-			$this->posxprogress-=20;
162
-			$this->posxdatestart-=20;
163
-			$this->posxdateend-=20;
164
-		}
165
-	}
106
+    public $marge_basse;
107
+
108
+    /**
109
+     * Issuer
110
+     * @var Company object that emits
111
+     */
112
+    public $emetteur;
113
+
114
+    /**
115
+     *	Constructor
116
+     *
117
+     *  @param		DoliDB		$db      Database handler
118
+     */
119
+    function __construct($db)
120
+    {
121
+        global $conf,$langs,$mysoc;
122
+
123
+        // Translations
124
+        $langs->loadLangs(array("main", "projects", "companies"));
125
+
126
+        $this->db = $db;
127
+        $this->name = "baleine";
128
+        $this->description = $langs->trans("DocumentModelBaleine");
129
+
130
+        // Dimension page pour format A4
131
+        $this->type = 'pdf';
132
+        $formatarray=pdf_getFormat();
133
+        $this->page_largeur = $formatarray['width'];
134
+        $this->page_hauteur = $formatarray['height'];
135
+        $this->format = array($this->page_largeur,$this->page_hauteur);
136
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
140
+
141
+        $this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
142
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
143
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
144
+
145
+        // Recupere emmetteur
146
+        $this->emetteur=$mysoc;
147
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
148
+
149
+        // Defini position des colonnes
150
+        $this->posxref=$this->marge_gauche+1;
151
+        $this->posxlabel=$this->marge_gauche+25;
152
+        $this->posxworkload=$this->marge_gauche+120;
153
+        $this->posxprogress=$this->marge_gauche+140;
154
+        $this->posxdatestart=$this->marge_gauche+152;
155
+        $this->posxdateend=$this->marge_gauche+170;
156
+        if ($this->page_largeur < 210) // To work with US executive format
157
+        {
158
+            $this->posxref-=20;
159
+            $this->posxlabel-=20;
160
+            $this->posxworkload-=20;
161
+            $this->posxprogress-=20;
162
+            $this->posxdatestart-=20;
163
+            $this->posxdateend-=20;
164
+        }
165
+    }
166 166
 
167 167
 
168 168
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
169
-	/**
170
-	 *  Fonction generant le projet sur le disque
171
-	 *
172
-	 *	@param	Project		$object   		Object project a generer
173
-	 *	@param	Translate	$outputlangs	Lang output object
174
-	 *	@return	int         				1 if OK, <=0 if KO
175
-	 */
176
-	function write_file($object,$outputlangs)
177
-	{
169
+    /**
170
+     *  Fonction generant le projet sur le disque
171
+     *
172
+     *	@param	Project		$object   		Object project a generer
173
+     *	@param	Translate	$outputlangs	Lang output object
174
+     *	@return	int         				1 if OK, <=0 if KO
175
+     */
176
+    function write_file($object,$outputlangs)
177
+    {
178 178
         // phpcs:enable
179
-		global $conf, $hookmanager, $langs, $user;
180
-
181
-		if (! is_object($outputlangs)) $outputlangs=$langs;
182
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
184
-
185
-		// Load traductions files requiredby by page
186
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
187
-
188
-		if ($conf->projet->dir_output)
189
-		{
190
-			//$nblignes = count($object->lines);  // This is set later with array of tasks
191
-
192
-			$objectref = dol_sanitizeFileName($object->ref);
193
-			$dir = $conf->projet->dir_output;
194
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195
-			$file = $dir . "/" . $objectref . ".pdf";
196
-
197
-			if (! file_exists($dir))
198
-			{
199
-				if (dol_mkdir($dir) < 0)
200
-				{
201
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
-					return 0;
203
-				}
204
-			}
205
-
206
-			if (file_exists($dir))
207
-			{
208
-				// Add pdfgeneration hook
209
-				if (! is_object($hookmanager))
210
-				{
211
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
-					$hookmanager=new HookManager($this->db);
213
-				}
214
-				$hookmanager->initHooks(array('pdfgeneration'));
215
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
-				global $action;
217
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
-
219
-				// Create pdf instance
220
-				$pdf=pdf_getInstance($this->format);
221
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
222
-				$pdf->SetAutoPageBreak(1,0);
223
-
224
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
225
-		        $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
226
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
179
+        global $conf, $hookmanager, $langs, $user;
180
+
181
+        if (! is_object($outputlangs)) $outputlangs=$langs;
182
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
184
+
185
+        // Load traductions files requiredby by page
186
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
187
+
188
+        if ($conf->projet->dir_output)
189
+        {
190
+            //$nblignes = count($object->lines);  // This is set later with array of tasks
191
+
192
+            $objectref = dol_sanitizeFileName($object->ref);
193
+            $dir = $conf->projet->dir_output;
194
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195
+            $file = $dir . "/" . $objectref . ".pdf";
196
+
197
+            if (! file_exists($dir))
198
+            {
199
+                if (dol_mkdir($dir) < 0)
200
+                {
201
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
+                    return 0;
203
+                }
204
+            }
205
+
206
+            if (file_exists($dir))
207
+            {
208
+                // Add pdfgeneration hook
209
+                if (! is_object($hookmanager))
210
+                {
211
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
+                    $hookmanager=new HookManager($this->db);
213
+                }
214
+                $hookmanager->initHooks(array('pdfgeneration'));
215
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
+                global $action;
217
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
+
219
+                // Create pdf instance
220
+                $pdf=pdf_getInstance($this->format);
221
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
222
+                $pdf->SetAutoPageBreak(1,0);
223
+
224
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
225
+                $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
226
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
228 228
 
229 229
                 if (class_exists('TCPDF'))
230 230
                 {
@@ -239,403 +239,403 @@  discard block
 block discarded – undo
239 239
                     $tplidx = $pdf->importPage(1);
240 240
                 }
241 241
 
242
-				// Complete object by loading several other informations
243
-				$task = new Task($this->db);
244
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
245
-
246
-				if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
247
-				{
248
-					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249
-				}
250
-
251
-				$object->lines=$tasksarray;
252
-				$nblignes=count($object->lines);
253
-
254
-				$pdf->Open();
255
-				$pagenb=0;
256
-				$pdf->SetDrawColor(128,128,128);
257
-
258
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
259
-				$pdf->SetSubject($outputlangs->transnoentities("Project"));
260
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
261
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264
-
265
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
266
-
267
-				// New page
268
-				$pdf->AddPage();
269
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
270
-				$pagenb++;
271
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
272
-				$pdf->SetFont('','', $default_font_size - 1);
273
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
274
-				$pdf->SetTextColor(0,0,0);
275
-
276
-				$tab_top = 50;
277
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
278
-				$tab_height = 170;
279
-				$tab_height_newpage = 190;
280
-
281
-				// Show public note
282
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
283
-				if ($notetoshow)
284
-				{
285
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
286
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
287
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288
-
289
-					$tab_top -= 2;
290
-
291
-					$pdf->SetFont('','', $default_font_size - 1);
292
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
293
-					$nexY = $pdf->GetY();
294
-					$height_note=$nexY-$tab_top;
295
-
296
-					// Rect prend une longueur en 3eme param
297
-					$pdf->SetDrawColor(192,192,192);
298
-					$pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
299
-
300
-					$tab_height = $tab_height - $height_note;
301
-					$tab_top = $nexY+6;
302
-				}
303
-				else
304
-				{
305
-					$height_note=0;
306
-				}
307
-
308
-				$heightoftitleline = 10;
309
-				$iniY = $tab_top + $heightoftitleline + 1;
310
-				$curY = $tab_top + $heightoftitleline + 1;
311
-				$nexY = $tab_top + $heightoftitleline + 1;
312
-
313
-				// Loop on each lines
314
-				for ($i = 0 ; $i < $nblignes ; $i++)
315
-				{
316
-					$curY = $nexY;
317
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
318
-					$pdf->SetTextColor(0,0,0);
319
-
320
-					$pdf->setTopMargin($tab_top_newpage);
321
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
322
-					$pageposbefore=$pdf->getPage();
323
-
324
-					// Description of line
325
-					$ref=$object->lines[$i]->ref;
326
-					$libelleline=$object->lines[$i]->label;
327
-					$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
329
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
330
-					$planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
331
-
332
-					$showpricebeforepagebreak=1;
333
-
334
-					$pdf->startTransaction();
335
-					// Label
336
-					$pdf->SetXY($this->posxlabel, $curY);
337
-					$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
-					$pageposafter=$pdf->getPage();
339
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
340
-					{
341
-						$pdf->rollbackTransaction(true);
342
-						$pageposafter=$pageposbefore;
343
-						//print $pageposafter.'-'.$pageposbefore;exit;
344
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
345
-						// Label
346
-						$pdf->SetXY($this->posxlabel, $curY);
347
-						$posybefore=$pdf->GetY();
348
-						$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
-						$pageposafter=$pdf->getPage();
350
-						$posyafter=$pdf->GetY();
351
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
352
-						{
353
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
354
-							{
355
-								$pdf->AddPage('','',true);
356
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358
-								$pdf->setPage($pageposafter+1);
359
-							}
360
-						}
361
-						else
362
-						{
363
-							// We found a page break
364
-							$showpricebeforepagebreak=0;
365
-							$forcedesconsamepage=1;
366
-							if ($forcedesconsamepage)
367
-							{
368
-								$pdf->rollbackTransaction(true);
369
-								$pageposafter=$pageposbefore;
370
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371
-
372
-								$pdf->AddPage('','',true);
373
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375
-								$pdf->setPage($pageposafter+1);
376
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
378
-								$pdf->SetTextColor(0,0,0);
379
-
380
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
381
-								$curY = $tab_top_newpage + $heightoftitleline + 1;
382
-
383
-								// Label
384
-								$pdf->SetXY($this->posxlabel, $curY);
385
-								$posybefore=$pdf->GetY();
386
-								$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
-								$pageposafter=$pdf->getPage();
388
-								$posyafter=$pdf->GetY();
389
-							}
390
-						}
391
-						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392
-					}
393
-					else	// No pagebreak
394
-					{
395
-						$pdf->commitTransaction();
396
-					}
397
-					$posYAfterDescription=$pdf->GetY();
398
-
399
-					$nexY = $pdf->GetY();
400
-					$pageposafter=$pdf->getPage();
401
-					$pdf->setPage($pageposbefore);
402
-					$pdf->setTopMargin($this->marge_haute);
403
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
404
-
405
-					// We suppose that a too long description is moved completely on next page
406
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
407
-						//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
408
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409
-					}
410
-
411
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
412
-
413
-					// Ref of task
414
-					$pdf->SetXY($this->posxref, $curY);
415
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416
-					// Workload
417
-					$pdf->SetXY($this->posxworkload, $curY);
418
-					$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
419
-					// Progress
420
-					$pdf->SetXY($this->posxprogress, $curY);
421
-					$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
422
-					// Date
423
-					$pdf->SetXY($this->posxdatestart, $curY);
424
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
425
-					$pdf->SetXY($this->posxdateend, $curY);
426
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
427
-
428
-					// Add line
429
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430
-					{
431
-						$pdf->setPage($pageposafter);
432
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
433
-						//$pdf->SetDrawColor(190,190,200);
434
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
435
-						$pdf->SetLineStyle(array('dash'=>0));
436
-					}
437
-
438
-					$nexY+=2;    // Passe espace entre les lignes
439
-
440
-					// Detect if some page were added automatically and output _tableau for past pages
441
-					while ($pagenb < $pageposafter)
442
-					{
443
-						$pdf->setPage($pagenb);
444
-						if ($pagenb == 1)
445
-						{
446
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447
-						}
448
-						else
449
-						{
450
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451
-						}
452
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
453
-						$pagenb++;
454
-						$pdf->setPage($pagenb);
455
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
456
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457
-					}
458
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459
-					{
460
-						if ($pagenb == 1)
461
-						{
462
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463
-						}
464
-						else
465
-						{
466
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467
-						}
468
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
469
-						// New page
470
-						$pdf->AddPage();
471
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
-						$pagenb++;
473
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474
-					}
475
-				}
476
-
477
-				// Show square
478
-				if ($pagenb == 1)
479
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480
-				else
481
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483
-
484
-				// Pied de page
485
-				$this->_pagefoot($pdf, $object, $outputlangs);
486
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
487
-
488
-				$pdf->Close();
489
-
490
-				$pdf->Output($file, 'F');
491
-
492
-				// Add pdfgeneration hook
493
-				$hookmanager->initHooks(array('pdfgeneration'));
494
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495
-				global $action;
496
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
497
-
498
-				if (! empty($conf->global->MAIN_UMASK))
499
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
500
-
501
-				$this->result = array('fullpath'=>$file);
502
-
503
-				return 1;   // Pas d'erreur
504
-			}
505
-			else
506
-			{
507
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508
-				return 0;
509
-			}
510
-		}
511
-		else
512
-		{
513
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514
-			return 0;
515
-		}
516
-	}
517
-
518
-
519
-	/**
520
-	 *   Show table for lines
521
-	 *
522
-	 *   @param		PDF			$pdf     		Object PDF
523
-	 *   @param		string		$tab_top		Top position of table
524
-	 *   @param		string		$tab_height		Height of table (rectangle)
525
-	 *   @param		int			$nexY			Y
526
-	 *   @param		Translate	$outputlangs	Langs object
527
-	 *   @param		int			$hidetop		Hide top bar of array
528
-	 *   @param		int			$hidebottom		Hide bottom bar of array
529
-	 *   @return	void
530
-	 */
531
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
532
-	{
533
-		global $conf,$mysoc;
534
-
535
-		$heightoftitleline = 10;
536
-
537
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
538
-
539
-		$pdf->SetDrawColor(128,128,128);
540
-
541
-		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
543
-
544
-		// line prend une position y en 3eme param
545
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
546
-
547
-		$pdf->SetTextColor(0,0,0);
548
-		$pdf->SetFont('','', $default_font_size);
549
-
550
-		$pdf->SetXY($this->posxref, $tab_top+1);
551
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
552
-
553
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
554
-		$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555
-
556
-		$pdf->SetXY($this->posxworkload, $tab_top+1);
557
-		$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558
-
559
-		$pdf->SetXY($this->posxprogress, $tab_top+1);
560
-		$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
561
-
562
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
563
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
564
-
565
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
566
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567
-	}
568
-
569
-	/**
570
-	 *  Show top header of page.
571
-	 *
572
-	 *  @param	PDF			$pdf     		Object PDF
573
-	 *  @param  Project		$object     	Object to show
574
-	 *  @param  int	    	$showaddress    0=no, 1=yes
575
-	 *  @param  Translate	$outputlangs	Object lang for output
576
-	 *  @return	void
577
-	 */
578
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579
-	{
580
-		global $langs,$conf,$mysoc;
581
-
582
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
242
+                // Complete object by loading several other informations
243
+                $task = new Task($this->db);
244
+                $tasksarray = $task->getTasksArray(0,0,$object->id);
245
+
246
+                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
247
+                {
248
+                    $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249
+                }
250
+
251
+                $object->lines=$tasksarray;
252
+                $nblignes=count($object->lines);
253
+
254
+                $pdf->Open();
255
+                $pagenb=0;
256
+                $pdf->SetDrawColor(128,128,128);
257
+
258
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
259
+                $pdf->SetSubject($outputlangs->transnoentities("Project"));
260
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
261
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264
+
265
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
266
+
267
+                // New page
268
+                $pdf->AddPage();
269
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
270
+                $pagenb++;
271
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
272
+                $pdf->SetFont('','', $default_font_size - 1);
273
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
274
+                $pdf->SetTextColor(0,0,0);
275
+
276
+                $tab_top = 50;
277
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
278
+                $tab_height = 170;
279
+                $tab_height_newpage = 190;
280
+
281
+                // Show public note
282
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
283
+                if ($notetoshow)
284
+                {
285
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
286
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
287
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288
+
289
+                    $tab_top -= 2;
583 290
 
584
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
585
-
586
-		$pdf->SetTextColor(0,0,60);
587
-		$pdf->SetFont('','B', $default_font_size + 3);
291
+                    $pdf->SetFont('','', $default_font_size - 1);
292
+                    $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
293
+                    $nexY = $pdf->GetY();
294
+                    $height_note=$nexY-$tab_top;
295
+
296
+                    // Rect prend une longueur en 3eme param
297
+                    $pdf->SetDrawColor(192,192,192);
298
+                    $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
299
+
300
+                    $tab_height = $tab_height - $height_note;
301
+                    $tab_top = $nexY+6;
302
+                }
303
+                else
304
+                {
305
+                    $height_note=0;
306
+                }
307
+
308
+                $heightoftitleline = 10;
309
+                $iniY = $tab_top + $heightoftitleline + 1;
310
+                $curY = $tab_top + $heightoftitleline + 1;
311
+                $nexY = $tab_top + $heightoftitleline + 1;
312
+
313
+                // Loop on each lines
314
+                for ($i = 0 ; $i < $nblignes ; $i++)
315
+                {
316
+                    $curY = $nexY;
317
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
318
+                    $pdf->SetTextColor(0,0,0);
319
+
320
+                    $pdf->setTopMargin($tab_top_newpage);
321
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
322
+                    $pageposbefore=$pdf->getPage();
323
+
324
+                    // Description of line
325
+                    $ref=$object->lines[$i]->ref;
326
+                    $libelleline=$object->lines[$i]->label;
327
+                    $progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328
+                    $datestart=dol_print_date($object->lines[$i]->date_start,'day');
329
+                    $dateend=dol_print_date($object->lines[$i]->date_end,'day');
330
+                    $planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
331
+
332
+                    $showpricebeforepagebreak=1;
333
+
334
+                    $pdf->startTransaction();
335
+                    // Label
336
+                    $pdf->SetXY($this->posxlabel, $curY);
337
+                    $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
+                    $pageposafter=$pdf->getPage();
339
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
340
+                    {
341
+                        $pdf->rollbackTransaction(true);
342
+                        $pageposafter=$pageposbefore;
343
+                        //print $pageposafter.'-'.$pageposbefore;exit;
344
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
345
+                        // Label
346
+                        $pdf->SetXY($this->posxlabel, $curY);
347
+                        $posybefore=$pdf->GetY();
348
+                        $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
+                        $pageposafter=$pdf->getPage();
350
+                        $posyafter=$pdf->GetY();
351
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
352
+                        {
353
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
354
+                            {
355
+                                $pdf->AddPage('','',true);
356
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358
+                                $pdf->setPage($pageposafter+1);
359
+                            }
360
+                        }
361
+                        else
362
+                        {
363
+                            // We found a page break
364
+                            $showpricebeforepagebreak=0;
365
+                            $forcedesconsamepage=1;
366
+                            if ($forcedesconsamepage)
367
+                            {
368
+                                $pdf->rollbackTransaction(true);
369
+                                $pageposafter=$pageposbefore;
370
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371
+
372
+                                $pdf->AddPage('','',true);
373
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375
+                                $pdf->setPage($pageposafter+1);
376
+                                $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377
+                                $pdf->MultiCell(0, 3, '');		// Set interline to 3
378
+                                $pdf->SetTextColor(0,0,0);
379
+
380
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
381
+                                $curY = $tab_top_newpage + $heightoftitleline + 1;
382
+
383
+                                // Label
384
+                                $pdf->SetXY($this->posxlabel, $curY);
385
+                                $posybefore=$pdf->GetY();
386
+                                $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
+                                $pageposafter=$pdf->getPage();
388
+                                $posyafter=$pdf->GetY();
389
+                            }
390
+                        }
391
+                        //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392
+                    }
393
+                    else	// No pagebreak
394
+                    {
395
+                        $pdf->commitTransaction();
396
+                    }
397
+                    $posYAfterDescription=$pdf->GetY();
398
+
399
+                    $nexY = $pdf->GetY();
400
+                    $pageposafter=$pdf->getPage();
401
+                    $pdf->setPage($pageposbefore);
402
+                    $pdf->setTopMargin($this->marge_haute);
403
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
404
+
405
+                    // We suppose that a too long description is moved completely on next page
406
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
407
+                        //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
408
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409
+                    }
410
+
411
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
412
+
413
+                    // Ref of task
414
+                    $pdf->SetXY($this->posxref, $curY);
415
+                    $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416
+                    // Workload
417
+                    $pdf->SetXY($this->posxworkload, $curY);
418
+                    $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
419
+                    // Progress
420
+                    $pdf->SetXY($this->posxprogress, $curY);
421
+                    $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
422
+                    // Date
423
+                    $pdf->SetXY($this->posxdatestart, $curY);
424
+                    $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
425
+                    $pdf->SetXY($this->posxdateend, $curY);
426
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
427
+
428
+                    // Add line
429
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430
+                    {
431
+                        $pdf->setPage($pageposafter);
432
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
433
+                        //$pdf->SetDrawColor(190,190,200);
434
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
435
+                        $pdf->SetLineStyle(array('dash'=>0));
436
+                    }
437
+
438
+                    $nexY+=2;    // Passe espace entre les lignes
439
+
440
+                    // Detect if some page were added automatically and output _tableau for past pages
441
+                    while ($pagenb < $pageposafter)
442
+                    {
443
+                        $pdf->setPage($pagenb);
444
+                        if ($pagenb == 1)
445
+                        {
446
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447
+                        }
448
+                        else
449
+                        {
450
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451
+                        }
452
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
453
+                        $pagenb++;
454
+                        $pdf->setPage($pagenb);
455
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
456
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457
+                    }
458
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459
+                    {
460
+                        if ($pagenb == 1)
461
+                        {
462
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463
+                        }
464
+                        else
465
+                        {
466
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467
+                        }
468
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
469
+                        // New page
470
+                        $pdf->AddPage();
471
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
+                        $pagenb++;
473
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474
+                    }
475
+                }
476
+
477
+                // Show square
478
+                if ($pagenb == 1)
479
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480
+                else
481
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483
+
484
+                // Pied de page
485
+                $this->_pagefoot($pdf, $object, $outputlangs);
486
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
487
+
488
+                $pdf->Close();
489
+
490
+                $pdf->Output($file, 'F');
491
+
492
+                // Add pdfgeneration hook
493
+                $hookmanager->initHooks(array('pdfgeneration'));
494
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495
+                global $action;
496
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
497
+
498
+                if (! empty($conf->global->MAIN_UMASK))
499
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
500
+
501
+                $this->result = array('fullpath'=>$file);
502
+
503
+                return 1;   // Pas d'erreur
504
+            }
505
+            else
506
+            {
507
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508
+                return 0;
509
+            }
510
+        }
511
+        else
512
+        {
513
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514
+            return 0;
515
+        }
516
+    }
517
+
518
+
519
+    /**
520
+     *   Show table for lines
521
+     *
522
+     *   @param		PDF			$pdf     		Object PDF
523
+     *   @param		string		$tab_top		Top position of table
524
+     *   @param		string		$tab_height		Height of table (rectangle)
525
+     *   @param		int			$nexY			Y
526
+     *   @param		Translate	$outputlangs	Langs object
527
+     *   @param		int			$hidetop		Hide top bar of array
528
+     *   @param		int			$hidebottom		Hide bottom bar of array
529
+     *   @return	void
530
+     */
531
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
532
+    {
533
+        global $conf,$mysoc;
534
+
535
+        $heightoftitleline = 10;
536
+
537
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
538
+
539
+        $pdf->SetDrawColor(128,128,128);
540
+
541
+        // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542
+        $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
543
+
544
+        // line prend une position y en 3eme param
545
+        $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
546
+
547
+        $pdf->SetTextColor(0,0,0);
548
+        $pdf->SetFont('','', $default_font_size);
549
+
550
+        $pdf->SetXY($this->posxref, $tab_top+1);
551
+        $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
552
+
553
+        $pdf->SetXY($this->posxlabel, $tab_top+1);
554
+        $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555
+
556
+        $pdf->SetXY($this->posxworkload, $tab_top+1);
557
+        $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558
+
559
+        $pdf->SetXY($this->posxprogress, $tab_top+1);
560
+        $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
561
+
562
+        $pdf->SetXY($this->posxdatestart, $tab_top+1);
563
+        $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
564
+
565
+        $pdf->SetXY($this->posxdateend, $tab_top+1);
566
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567
+    }
568
+
569
+    /**
570
+     *  Show top header of page.
571
+     *
572
+     *  @param	PDF			$pdf     		Object PDF
573
+     *  @param  Project		$object     	Object to show
574
+     *  @param  int	    	$showaddress    0=no, 1=yes
575
+     *  @param  Translate	$outputlangs	Object lang for output
576
+     *  @return	void
577
+     */
578
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579
+    {
580
+        global $langs,$conf,$mysoc;
581
+
582
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
583
+
584
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
585
+
586
+        $pdf->SetTextColor(0,0,60);
587
+        $pdf->SetFont('','B', $default_font_size + 3);
588 588
 
589 589
         $posx=$this->page_largeur-$this->marge_droite-100;
590
-		$posy=$this->marge_haute;
591
-
592
-		$pdf->SetXY($this->marge_gauche,$posy);
593
-
594
-		// Logo
595
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596
-		if ($mysoc->logo)
597
-		{
598
-			if (is_readable($logo))
599
-			{
600
-			    $height=pdf_getHeightForLogo($logo);
601
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
602
-			}
603
-			else
604
-			{
605
-				$pdf->SetTextColor(200,0,0);
606
-				$pdf->SetFont('','B', $default_font_size - 2);
607
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609
-			}
610
-		}
611
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612
-
613
-		$pdf->SetFont('','B', $default_font_size + 3);
614
-		$pdf->SetXY($posx,$posy);
615
-		$pdf->SetTextColor(0,0,60);
616
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617
-		$pdf->SetFont('','', $default_font_size + 2);
618
-
619
-		$posy+=6;
620
-		$pdf->SetXY($posx,$posy);
621
-		$pdf->SetTextColor(0,0,60);
622
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
623
-
624
-		$posy+=6;
625
-		$pdf->SetXY($posx,$posy);
626
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
627
-
628
-		if (is_object($object->thirdparty))
629
-		{
630
-			$posy+=6;
631
-			$pdf->SetXY($posx,$posy);
632
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
633
-		}
634
-
635
-		$pdf->SetTextColor(0,0,60);
636
-
637
-		// Add list of linked objects
638
-		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
590
+        $posy=$this->marge_haute;
591
+
592
+        $pdf->SetXY($this->marge_gauche,$posy);
593
+
594
+        // Logo
595
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596
+        if ($mysoc->logo)
597
+        {
598
+            if (is_readable($logo))
599
+            {
600
+                $height=pdf_getHeightForLogo($logo);
601
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
602
+            }
603
+            else
604
+            {
605
+                $pdf->SetTextColor(200,0,0);
606
+                $pdf->SetFont('','B', $default_font_size - 2);
607
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609
+            }
610
+        }
611
+        else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612
+
613
+        $pdf->SetFont('','B', $default_font_size + 3);
614
+        $pdf->SetXY($posx,$posy);
615
+        $pdf->SetTextColor(0,0,60);
616
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617
+        $pdf->SetFont('','', $default_font_size + 2);
618
+
619
+        $posy+=6;
620
+        $pdf->SetXY($posx,$posy);
621
+        $pdf->SetTextColor(0,0,60);
622
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
623
+
624
+        $posy+=6;
625
+        $pdf->SetXY($posx,$posy);
626
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
627
+
628
+        if (is_object($object->thirdparty))
629
+        {
630
+            $posy+=6;
631
+            $pdf->SetXY($posx,$posy);
632
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
633
+        }
634
+
635
+        $pdf->SetTextColor(0,0,60);
636
+
637
+        // Add list of linked objects
638
+        /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
639 639
 		$object->fetchObjectLinked();
640 640
 
641 641
 	    foreach($object->linkedObjects as $objecttype => $objects)
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
 	    	}
658 658
 	    }
659 659
         */
660
-	}
660
+    }
661 661
 
662
-	/**
663
-	 *   	Show footer of page. Need this->emetteur object
662
+    /**
663
+     *   	Show footer of page. Need this->emetteur object
664 664
      *
665
-	 *   	@param	PDF			$pdf     			PDF
666
-	 * 		@param	Project		$object				Object to show
667
-	 *      @param	Translate	$outputlangs		Object lang for output
668
-	 *      @param	int			$hidefreetext		1=Hide free text
669
-	 *      @return	integer
670
-	 */
671
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
672
-	{
673
-		global $conf;
674
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
676
-	}
665
+     *   	@param	PDF			$pdf     			PDF
666
+     * 		@param	Project		$object				Object to show
667
+     *      @param	Translate	$outputlangs		Object lang for output
668
+     *      @param	int			$hidefreetext		1=Hide free text
669
+     *      @return	integer
670
+     */
671
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
672
+    {
673
+        global $conf;
674
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
+        return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
676
+    }
677 677
 }
Please login to merge, or discard this patch.
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	function __construct($db)
120 120
 	{
121
-		global $conf,$langs,$mysoc;
121
+		global $conf, $langs, $mysoc;
122 122
 
123 123
 		// Translations
124 124
 		$langs->loadLangs(array("main", "projects", "companies"));
@@ -129,38 +129,38 @@  discard block
 block discarded – undo
129 129
 
130 130
 		// Dimension page pour format A4
131 131
 		$this->type = 'pdf';
132
-		$formatarray=pdf_getFormat();
132
+		$formatarray = pdf_getFormat();
133 133
 		$this->page_largeur = $formatarray['width'];
134 134
 		$this->page_hauteur = $formatarray['height'];
135
-		$this->format = array($this->page_largeur,$this->page_hauteur);
136
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
135
+		$this->format = array($this->page_largeur, $this->page_hauteur);
136
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
137
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
138
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
139
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
140 140
 
141
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
142
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
143
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
141
+		$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
142
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
143
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
144 144
 
145 145
 		// Recupere emmetteur
146
-		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
146
+		$this->emetteur = $mysoc;
147
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
148 148
 
149 149
 		// Defini position des colonnes
150
-		$this->posxref=$this->marge_gauche+1;
151
-		$this->posxlabel=$this->marge_gauche+25;
152
-		$this->posxworkload=$this->marge_gauche+120;
153
-		$this->posxprogress=$this->marge_gauche+140;
154
-		$this->posxdatestart=$this->marge_gauche+152;
155
-		$this->posxdateend=$this->marge_gauche+170;
150
+		$this->posxref = $this->marge_gauche + 1;
151
+		$this->posxlabel = $this->marge_gauche + 25;
152
+		$this->posxworkload = $this->marge_gauche + 120;
153
+		$this->posxprogress = $this->marge_gauche + 140;
154
+		$this->posxdatestart = $this->marge_gauche + 152;
155
+		$this->posxdateend = $this->marge_gauche + 170;
156 156
 		if ($this->page_largeur < 210) // To work with US executive format
157 157
 		{
158
-			$this->posxref-=20;
159
-			$this->posxlabel-=20;
160
-			$this->posxworkload-=20;
161
-			$this->posxprogress-=20;
162
-			$this->posxdatestart-=20;
163
-			$this->posxdateend-=20;
158
+			$this->posxref -= 20;
159
+			$this->posxlabel -= 20;
160
+			$this->posxworkload -= 20;
161
+			$this->posxprogress -= 20;
162
+			$this->posxdatestart -= 20;
163
+			$this->posxdateend -= 20;
164 164
 		}
165 165
 	}
166 166
 
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 	 *	@param	Translate	$outputlangs	Lang output object
174 174
 	 *	@return	int         				1 if OK, <=0 if KO
175 175
 	 */
176
-	function write_file($object,$outputlangs)
176
+	function write_file($object, $outputlangs)
177 177
 	{
178 178
         // phpcs:enable
179 179
 		global $conf, $hookmanager, $langs, $user;
180 180
 
181
-		if (! is_object($outputlangs)) $outputlangs=$langs;
181
+		if (!is_object($outputlangs)) $outputlangs = $langs;
182 182
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
183
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
184 184
 
185 185
 		// Load traductions files requiredby by page
186 186
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 
192 192
 			$objectref = dol_sanitizeFileName($object->ref);
193 193
 			$dir = $conf->projet->dir_output;
194
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195
-			$file = $dir . "/" . $objectref . ".pdf";
194
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
195
+			$file = $dir."/".$objectref.".pdf";
196 196
 
197
-			if (! file_exists($dir))
197
+			if (!file_exists($dir))
198 198
 			{
199 199
 				if (dol_mkdir($dir) < 0)
200 200
 				{
201
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
201
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
202 202
 					return 0;
203 203
 				}
204 204
 			}
@@ -206,25 +206,25 @@  discard block
 block discarded – undo
206 206
 			if (file_exists($dir))
207 207
 			{
208 208
 				// Add pdfgeneration hook
209
-				if (! is_object($hookmanager))
209
+				if (!is_object($hookmanager))
210 210
 				{
211 211
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212
-					$hookmanager=new HookManager($this->db);
212
+					$hookmanager = new HookManager($this->db);
213 213
 				}
214 214
 				$hookmanager->initHooks(array('pdfgeneration'));
215
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
216 216
 				global $action;
217
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
217
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
218 218
 
219 219
 				// Create pdf instance
220
-				$pdf=pdf_getInstance($this->format);
221
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
222
-				$pdf->SetAutoPageBreak(1,0);
220
+				$pdf = pdf_getInstance($this->format);
221
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
222
+				$pdf->SetAutoPageBreak(1, 0);
223 223
 
224
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
225
-		        $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
226
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
224
+				$heightforinfotot = 40; // Height reserved to output the info and total part
225
+		        $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
226
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
227
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
228 228
 
229 229
                 if (class_exists('TCPDF'))
230 230
                 {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 }
234 234
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
235 235
                 // Set path to the background PDF File
236
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
236
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237 237
                 {
238 238
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239 239
                     $tplidx = $pdf->importPage(1);
@@ -241,68 +241,68 @@  discard block
 block discarded – undo
241 241
 
242 242
 				// Complete object by loading several other informations
243 243
 				$task = new Task($this->db);
244
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
244
+				$tasksarray = $task->getTasksArray(0, 0, $object->id);
245 245
 
246
-				if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
246
+				if (!$object->id > 0)  // Special case when used with object = specimen, we may return all lines
247 247
 				{
248
-					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
248
+					$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
249 249
 				}
250 250
 
251
-				$object->lines=$tasksarray;
252
-				$nblignes=count($object->lines);
251
+				$object->lines = $tasksarray;
252
+				$nblignes = count($object->lines);
253 253
 
254 254
 				$pdf->Open();
255
-				$pagenb=0;
256
-				$pdf->SetDrawColor(128,128,128);
255
+				$pagenb = 0;
256
+				$pdf->SetDrawColor(128, 128, 128);
257 257
 
258 258
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
259 259
 				$pdf->SetSubject($outputlangs->transnoentities("Project"));
260 260
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
261 261
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262 262
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
263
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264 264
 
265
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
265
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
266 266
 
267 267
 				// New page
268 268
 				$pdf->AddPage();
269
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
269
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
270 270
 				$pagenb++;
271 271
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
272
-				$pdf->SetFont('','', $default_font_size - 1);
273
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
274
-				$pdf->SetTextColor(0,0,0);
272
+				$pdf->SetFont('', '', $default_font_size - 1);
273
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
274
+				$pdf->SetTextColor(0, 0, 0);
275 275
 
276 276
 				$tab_top = 50;
277
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
277
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
278 278
 				$tab_height = 170;
279 279
 				$tab_height_newpage = 190;
280 280
 
281 281
 				// Show public note
282
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
282
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
283 283
 				if ($notetoshow)
284 284
 				{
285
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
285
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
286 286
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
287 287
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288 288
 
289 289
 					$tab_top -= 2;
290 290
 
291
-					$pdf->SetFont('','', $default_font_size - 1);
292
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
291
+					$pdf->SetFont('', '', $default_font_size - 1);
292
+					$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
293 293
 					$nexY = $pdf->GetY();
294
-					$height_note=$nexY-$tab_top;
294
+					$height_note = $nexY - $tab_top;
295 295
 
296 296
 					// Rect prend une longueur en 3eme param
297
-					$pdf->SetDrawColor(192,192,192);
298
-					$pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
297
+					$pdf->SetDrawColor(192, 192, 192);
298
+					$pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2);
299 299
 
300 300
 					$tab_height = $tab_height - $height_note;
301
-					$tab_top = $nexY+6;
301
+					$tab_top = $nexY + 6;
302 302
 				}
303 303
 				else
304 304
 				{
305
-					$height_note=0;
305
+					$height_note = 0;
306 306
 				}
307 307
 
308 308
 				$heightoftitleline = 10;
@@ -311,81 +311,81 @@  discard block
 block discarded – undo
311 311
 				$nexY = $tab_top + $heightoftitleline + 1;
312 312
 
313 313
 				// Loop on each lines
314
-				for ($i = 0 ; $i < $nblignes ; $i++)
314
+				for ($i = 0; $i < $nblignes; $i++)
315 315
 				{
316 316
 					$curY = $nexY;
317
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
318
-					$pdf->SetTextColor(0,0,0);
317
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
318
+					$pdf->SetTextColor(0, 0, 0);
319 319
 
320 320
 					$pdf->setTopMargin($tab_top_newpage);
321
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
322
-					$pageposbefore=$pdf->getPage();
321
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
322
+					$pageposbefore = $pdf->getPage();
323 323
 
324 324
 					// Description of line
325
-					$ref=$object->lines[$i]->ref;
326
-					$libelleline=$object->lines[$i]->label;
327
-					$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
329
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
330
-					$planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
325
+					$ref = $object->lines[$i]->ref;
326
+					$libelleline = $object->lines[$i]->label;
327
+					$progress = ($object->lines[$i]->progress ? $object->lines[$i]->progress.'%' : '');
328
+					$datestart = dol_print_date($object->lines[$i]->date_start, 'day');
329
+					$dateend = dol_print_date($object->lines[$i]->date_end, 'day');
330
+					$planned_workload = convertSecondToTime((int) $object->lines[$i]->planned_workload, 'allhourmin');
331 331
 
332
-					$showpricebeforepagebreak=1;
332
+					$showpricebeforepagebreak = 1;
333 333
 
334 334
 					$pdf->startTransaction();
335 335
 					// Label
336 336
 					$pdf->SetXY($this->posxlabel, $curY);
337
-					$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
-					$pageposafter=$pdf->getPage();
337
+					$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338
+					$pageposafter = $pdf->getPage();
339 339
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
340 340
 					{
341 341
 						$pdf->rollbackTransaction(true);
342
-						$pageposafter=$pageposbefore;
342
+						$pageposafter = $pageposbefore;
343 343
 						//print $pageposafter.'-'.$pageposbefore;exit;
344
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
344
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
345 345
 						// Label
346 346
 						$pdf->SetXY($this->posxlabel, $curY);
347
-						$posybefore=$pdf->GetY();
348
-						$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
-						$pageposafter=$pdf->getPage();
350
-						$posyafter=$pdf->GetY();
351
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
347
+						$posybefore = $pdf->GetY();
348
+						$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349
+						$pageposafter = $pdf->getPage();
350
+						$posyafter = $pdf->GetY();
351
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
352 352
 						{
353
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
353
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
354 354
 							{
355
-								$pdf->AddPage('','',true);
356
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
355
+								$pdf->AddPage('', '', true);
356
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
357 357
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358
-								$pdf->setPage($pageposafter+1);
358
+								$pdf->setPage($pageposafter + 1);
359 359
 							}
360 360
 						}
361 361
 						else
362 362
 						{
363 363
 							// We found a page break
364
-							$showpricebeforepagebreak=0;
365
-							$forcedesconsamepage=1;
364
+							$showpricebeforepagebreak = 0;
365
+							$forcedesconsamepage = 1;
366 366
 							if ($forcedesconsamepage)
367 367
 							{
368 368
 								$pdf->rollbackTransaction(true);
369
-								$pageposafter=$pageposbefore;
370
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
369
+								$pageposafter = $pageposbefore;
370
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
371 371
 
372
-								$pdf->AddPage('','',true);
373
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
372
+								$pdf->AddPage('', '', true);
373
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
374 374
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375
-								$pdf->setPage($pageposafter+1);
376
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
378
-								$pdf->SetTextColor(0,0,0);
375
+								$pdf->setPage($pageposafter + 1);
376
+								$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
377
+								$pdf->MultiCell(0, 3, ''); // Set interline to 3
378
+								$pdf->SetTextColor(0, 0, 0);
379 379
 
380
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
380
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
381 381
 								$curY = $tab_top_newpage + $heightoftitleline + 1;
382 382
 
383 383
 								// Label
384 384
 								$pdf->SetXY($this->posxlabel, $curY);
385
-								$posybefore=$pdf->GetY();
386
-								$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
-								$pageposafter=$pdf->getPage();
388
-								$posyafter=$pdf->GetY();
385
+								$posybefore = $pdf->GetY();
386
+								$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387
+								$pageposafter = $pdf->getPage();
388
+								$posyafter = $pdf->GetY();
389 389
 							}
390 390
 						}
391 391
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 					{
395 395
 						$pdf->commitTransaction();
396 396
 					}
397
-					$posYAfterDescription=$pdf->GetY();
397
+					$posYAfterDescription = $pdf->GetY();
398 398
 
399 399
 					$nexY = $pdf->GetY();
400
-					$pageposafter=$pdf->getPage();
400
+					$pageposafter = $pdf->getPage();
401 401
 					$pdf->setPage($pageposbefore);
402 402
 					$pdf->setTopMargin($this->marge_haute);
403
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
403
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
404 404
 
405 405
 					// We suppose that a too long description is moved completely on next page
406 406
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -408,34 +408,34 @@  discard block
 block discarded – undo
408 408
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409 409
 					}
410 410
 
411
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
411
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
412 412
 
413 413
 					// Ref of task
414 414
 					$pdf->SetXY($this->posxref, $curY);
415
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
415
+					$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416 416
 					// Workload
417 417
 					$pdf->SetXY($this->posxworkload, $curY);
418
-					$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
418
+					$pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload ? $planned_workload : '', 0, 'R');
419 419
 					// Progress
420 420
 					$pdf->SetXY($this->posxprogress, $curY);
421
-					$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
421
+					$pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
422 422
 					// Date
423 423
 					$pdf->SetXY($this->posxdatestart, $curY);
424
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
424
+					$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
425 425
 					$pdf->SetXY($this->posxdateend, $curY);
426
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
426
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
427 427
 
428 428
 					// Add line
429
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
429
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430 430
 					{
431 431
 						$pdf->setPage($pageposafter);
432
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
432
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
433 433
 						//$pdf->SetDrawColor(190,190,200);
434
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
434
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
435 435
 						$pdf->SetLineStyle(array('dash'=>0));
436 436
 					}
437 437
 
438
-					$nexY+=2;    // Passe espace entre les lignes
438
+					$nexY += 2; // Passe espace entre les lignes
439 439
 
440 440
 					// Detect if some page were added automatically and output _tableau for past pages
441 441
 					while ($pagenb < $pageposafter)
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 						{
450 450
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451 451
 						}
452
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
452
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
453 453
 						$pagenb++;
454 454
 						$pdf->setPage($pagenb);
455
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
455
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
456 456
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457 457
 					}
458
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
458
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
459 459
 					{
460 460
 						if ($pagenb == 1)
461 461
 						{
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 						{
466 466
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467 467
 						}
468
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
468
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
469 469
 						// New page
470 470
 						$pdf->AddPage();
471
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
471
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
472 472
 						$pagenb++;
473 473
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474 474
 					}
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480 480
 				else
481 481
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
482
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483 483
 
484 484
 				// Pied de page
485 485
 				$this->_pagefoot($pdf, $object, $outputlangs);
@@ -491,26 +491,26 @@  discard block
 block discarded – undo
491 491
 
492 492
 				// Add pdfgeneration hook
493 493
 				$hookmanager->initHooks(array('pdfgeneration'));
494
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
494
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495 495
 				global $action;
496
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
496
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
497 497
 
498
-				if (! empty($conf->global->MAIN_UMASK))
498
+				if (!empty($conf->global->MAIN_UMASK))
499 499
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
500 500
 
501 501
 				$this->result = array('fullpath'=>$file);
502 502
 
503
-				return 1;   // Pas d'erreur
503
+				return 1; // Pas d'erreur
504 504
 			}
505 505
 			else
506 506
 			{
507
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
507
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
508 508
 				return 0;
509 509
 			}
510 510
 		}
511 511
 		else
512 512
 		{
513
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
513
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
514 514
 			return 0;
515 515
 		}
516 516
 	}
@@ -528,41 +528,41 @@  discard block
 block discarded – undo
528 528
 	 *   @param		int			$hidebottom		Hide bottom bar of array
529 529
 	 *   @return	void
530 530
 	 */
531
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
531
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
532 532
 	{
533
-		global $conf,$mysoc;
533
+		global $conf, $mysoc;
534 534
 
535 535
 		$heightoftitleline = 10;
536 536
 
537 537
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
538 538
 
539
-		$pdf->SetDrawColor(128,128,128);
539
+		$pdf->SetDrawColor(128, 128, 128);
540 540
 
541 541
 		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
542
+		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
543 543
 
544 544
 		// line prend une position y en 3eme param
545
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
545
+		$pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
546 546
 
547
-		$pdf->SetTextColor(0,0,0);
548
-		$pdf->SetFont('','', $default_font_size);
547
+		$pdf->SetTextColor(0, 0, 0);
548
+		$pdf->SetFont('', '', $default_font_size);
549 549
 
550
-		$pdf->SetXY($this->posxref, $tab_top+1);
551
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
550
+		$pdf->SetXY($this->posxref, $tab_top + 1);
551
+		$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
552 552
 
553
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
554
-		$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
553
+		$pdf->SetXY($this->posxlabel, $tab_top + 1);
554
+		$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555 555
 
556
-		$pdf->SetXY($this->posxworkload, $tab_top+1);
557
-		$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
556
+		$pdf->SetXY($this->posxworkload, $tab_top + 1);
557
+		$pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558 558
 
559
-		$pdf->SetXY($this->posxprogress, $tab_top+1);
560
-		$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
559
+		$pdf->SetXY($this->posxprogress, $tab_top + 1);
560
+		$pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
561 561
 
562
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
563
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
562
+		$pdf->SetXY($this->posxdatestart, $tab_top + 1);
563
+		$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C');
564 564
 
565
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
565
+		$pdf->SetXY($this->posxdateend, $tab_top + 1);
566 566
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567 567
 	}
568 568
 
@@ -577,62 +577,62 @@  discard block
 block discarded – undo
577 577
 	 */
578 578
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579 579
 	{
580
-		global $langs,$conf,$mysoc;
580
+		global $langs, $conf, $mysoc;
581 581
 
582 582
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
583 583
 
584
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
584
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
585 585
 
586
-		$pdf->SetTextColor(0,0,60);
587
-		$pdf->SetFont('','B', $default_font_size + 3);
586
+		$pdf->SetTextColor(0, 0, 60);
587
+		$pdf->SetFont('', 'B', $default_font_size + 3);
588 588
 
589
-        $posx=$this->page_largeur-$this->marge_droite-100;
590
-		$posy=$this->marge_haute;
589
+        $posx = $this->page_largeur - $this->marge_droite - 100;
590
+		$posy = $this->marge_haute;
591 591
 
592
-		$pdf->SetXY($this->marge_gauche,$posy);
592
+		$pdf->SetXY($this->marge_gauche, $posy);
593 593
 
594 594
 		// Logo
595
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
595
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596 596
 		if ($mysoc->logo)
597 597
 		{
598 598
 			if (is_readable($logo))
599 599
 			{
600
-			    $height=pdf_getHeightForLogo($logo);
601
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
600
+			    $height = pdf_getHeightForLogo($logo);
601
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
602 602
 			}
603 603
 			else
604 604
 			{
605
-				$pdf->SetTextColor(200,0,0);
606
-				$pdf->SetFont('','B', $default_font_size - 2);
607
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
605
+				$pdf->SetTextColor(200, 0, 0);
606
+				$pdf->SetFont('', 'B', $default_font_size - 2);
607
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
608 608
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609 609
 			}
610 610
 		}
611 611
 		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612 612
 
613
-		$pdf->SetFont('','B', $default_font_size + 3);
614
-		$pdf->SetXY($posx,$posy);
615
-		$pdf->SetTextColor(0,0,60);
613
+		$pdf->SetFont('', 'B', $default_font_size + 3);
614
+		$pdf->SetXY($posx, $posy);
615
+		$pdf->SetTextColor(0, 0, 60);
616 616
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617
-		$pdf->SetFont('','', $default_font_size + 2);
617
+		$pdf->SetFont('', '', $default_font_size + 2);
618 618
 
619
-		$posy+=6;
620
-		$pdf->SetXY($posx,$posy);
621
-		$pdf->SetTextColor(0,0,60);
622
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
619
+		$posy += 6;
620
+		$pdf->SetXY($posx, $posy);
621
+		$pdf->SetTextColor(0, 0, 60);
622
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
623 623
 
624
-		$posy+=6;
625
-		$pdf->SetXY($posx,$posy);
626
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
624
+		$posy += 6;
625
+		$pdf->SetXY($posx, $posy);
626
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
627 627
 
628 628
 		if (is_object($object->thirdparty))
629 629
 		{
630
-			$posy+=6;
631
-			$pdf->SetXY($posx,$posy);
632
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
630
+			$posy += 6;
631
+			$pdf->SetXY($posx, $posy);
632
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
633 633
 		}
634 634
 
635
-		$pdf->SetTextColor(0,0,60);
635
+		$pdf->SetTextColor(0, 0, 60);
636 636
 
637 637
 		// Add list of linked objects
638 638
 		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
@@ -668,10 +668,10 @@  discard block
 block discarded – undo
668 668
 	 *      @param	int			$hidefreetext		1=Hide free text
669 669
 	 *      @return	integer
670 670
 	 */
671
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
671
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
672 672
 	{
673 673
 		global $conf;
674
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
674
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675
+		return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
676 676
 	}
677 677
 }
Please login to merge, or discard this patch.
Braces   +76 added lines, -42 removed lines patch added patch discarded remove patch
@@ -144,7 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Recupere emmetteur
146 146
 		$this->emetteur=$mysoc;
147
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
147
+		if (! $this->emetteur->country_code) {
148
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
149
+		}
150
+		// By default if not defined
148 151
 
149 152
 		// Defini position des colonnes
150 153
 		$this->posxref=$this->marge_gauche+1;
@@ -153,9 +156,11 @@  discard block
 block discarded – undo
153 156
 		$this->posxprogress=$this->marge_gauche+140;
154 157
 		$this->posxdatestart=$this->marge_gauche+152;
155 158
 		$this->posxdateend=$this->marge_gauche+170;
156
-		if ($this->page_largeur < 210) // To work with US executive format
159
+		if ($this->page_largeur < 210) {
160
+		    // To work with US executive format
157 161
 		{
158 162
 			$this->posxref-=20;
163
+		}
159 164
 			$this->posxlabel-=20;
160 165
 			$this->posxworkload-=20;
161 166
 			$this->posxprogress-=20;
@@ -178,9 +183,13 @@  discard block
 block discarded – undo
178 183
         // phpcs:enable
179 184
 		global $conf, $hookmanager, $langs, $user;
180 185
 
181
-		if (! is_object($outputlangs)) $outputlangs=$langs;
186
+		if (! is_object($outputlangs)) {
187
+		    $outputlangs=$langs;
188
+		}
182 189
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
190
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
191
+		    $outputlangs->charset_output='ISO-8859-1';
192
+		}
184 193
 
185 194
 		// Load traductions files requiredby by page
186 195
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -191,7 +200,9 @@  discard block
 block discarded – undo
191 200
 
192 201
 			$objectref = dol_sanitizeFileName($object->ref);
193 202
 			$dir = $conf->projet->dir_output;
194
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
203
+			if (! preg_match('/specimen/i',$objectref)) {
204
+			    $dir.= "/" . $objectref;
205
+			}
195 206
 			$file = $dir . "/" . $objectref . ".pdf";
196 207
 
197 208
 			if (! file_exists($dir))
@@ -224,7 +235,9 @@  discard block
 block discarded – undo
224 235
 				$heightforinfotot = 40;	// Height reserved to output the info and total part
225 236
 		        $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
226 237
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
227
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
238
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
239
+	                $heightforfooter+= 6;
240
+	            }
228 241
 
229 242
                 if (class_exists('TCPDF'))
230 243
                 {
@@ -243,10 +256,12 @@  discard block
 block discarded – undo
243 256
 				$task = new Task($this->db);
244 257
 				$tasksarray = $task->getTasksArray(0,0,$object->id);
245 258
 
246
-				if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
259
+				if (! $object->id > 0) {
260
+				    // Special case when used with object = specimen, we may return all lines
247 261
 				{
248 262
 					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249 263
 				}
264
+				}
250 265
 
251 266
 				$object->lines=$tasksarray;
252 267
 				$nblignes=count($object->lines);
@@ -260,13 +275,17 @@  discard block
 block discarded – undo
260 275
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
261 276
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
262 277
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
263
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
278
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
279
+				    $pdf->SetCompression(false);
280
+				}
264 281
 
265 282
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
266 283
 
267 284
 				// New page
268 285
 				$pdf->AddPage();
269
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
286
+				if (! empty($tplidx)) {
287
+				    $pdf->useTemplate($tplidx);
288
+				}
270 289
 				$pagenb++;
271 290
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
272 291
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -299,8 +318,7 @@  discard block
 block discarded – undo
299 318
 
300 319
 					$tab_height = $tab_height - $height_note;
301 320
 					$tab_top = $nexY+6;
302
-				}
303
-				else
321
+				} else
304 322
 				{
305 323
 					$height_note=0;
306 324
 				}
@@ -336,9 +354,11 @@  discard block
 block discarded – undo
336 354
 					$pdf->SetXY($this->posxlabel, $curY);
337 355
 					$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338 356
 					$pageposafter=$pdf->getPage();
339
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
357
+					if ($pageposafter > $pageposbefore) {
358
+					    // There is a pagebreak
340 359
 					{
341 360
 						$pdf->rollbackTransaction(true);
361
+					}
342 362
 						$pageposafter=$pageposbefore;
343 363
 						//print $pageposafter.'-'.$pageposbefore;exit;
344 364
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -348,17 +368,22 @@  discard block
 block discarded – undo
348 368
 						$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
349 369
 						$pageposafter=$pdf->getPage();
350 370
 						$posyafter=$pdf->GetY();
351
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
371
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
372
+						    // There is no space left for total+free text
352 373
 						{
353 374
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
354 375
 							{
355 376
 								$pdf->AddPage('','',true);
356
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
377
+						}
378
+								if (! empty($tplidx)) {
379
+								    $pdf->useTemplate($tplidx);
380
+								}
381
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
382
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
383
+								}
358 384
 								$pdf->setPage($pageposafter+1);
359 385
 							}
360
-						}
361
-						else
386
+						} else
362 387
 						{
363 388
 							// We found a page break
364 389
 							$showpricebeforepagebreak=0;
@@ -370,8 +395,12 @@  discard block
 block discarded – undo
370 395
 								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371 396
 
372 397
 								$pdf->AddPage('','',true);
373
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
398
+								if (! empty($tplidx)) {
399
+								    $pdf->useTemplate($tplidx);
400
+								}
401
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
402
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
403
+								}
375 404
 								$pdf->setPage($pageposafter+1);
376 405
 								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
377 406
 								$pdf->MultiCell(0, 3, '');		// Set interline to 3
@@ -389,8 +418,7 @@  discard block
 block discarded – undo
389 418
 							}
390 419
 						}
391 420
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392
-					}
393
-					else	// No pagebreak
421
+					} else	// No pagebreak
394 422
 					{
395 423
 						$pdf->commitTransaction();
396 424
 					}
@@ -444,8 +472,7 @@  discard block
 block discarded – undo
444 472
 						if ($pagenb == 1)
445 473
 						{
446 474
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447
-						}
448
-						else
475
+						} else
449 476
 						{
450 477
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451 478
 						}
@@ -453,37 +480,45 @@  discard block
 block discarded – undo
453 480
 						$pagenb++;
454 481
 						$pdf->setPage($pagenb);
455 482
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
456
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
483
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
484
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
485
+						}
457 486
 					}
458 487
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459 488
 					{
460 489
 						if ($pagenb == 1)
461 490
 						{
462 491
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463
-						}
464
-						else
492
+						} else
465 493
 						{
466 494
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467 495
 						}
468 496
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
469 497
 						// New page
470 498
 						$pdf->AddPage();
471
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
499
+						if (! empty($tplidx)) {
500
+						    $pdf->useTemplate($tplidx);
501
+						}
472 502
 						$pagenb++;
473
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
503
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
504
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
505
+						}
474 506
 					}
475 507
 				}
476 508
 
477 509
 				// Show square
478
-				if ($pagenb == 1)
479
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480
-				else
481
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
510
+				if ($pagenb == 1) {
511
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
512
+				} else {
513
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
514
+				}
482 515
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483 516
 
484 517
 				// Pied de page
485 518
 				$this->_pagefoot($pdf, $object, $outputlangs);
486
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
519
+				if (method_exists($pdf, 'AliasNbPages')) {
520
+				    $pdf->AliasNbPages();
521
+				}
487 522
 
488 523
 				$pdf->Close();
489 524
 
@@ -495,20 +530,19 @@  discard block
 block discarded – undo
495 530
 				global $action;
496 531
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
497 532
 
498
-				if (! empty($conf->global->MAIN_UMASK))
499
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
533
+				if (! empty($conf->global->MAIN_UMASK)) {
534
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
535
+				}
500 536
 
501 537
 				$this->result = array('fullpath'=>$file);
502 538
 
503 539
 				return 1;   // Pas d'erreur
504
-			}
505
-			else
540
+			} else
506 541
 			{
507 542
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508 543
 				return 0;
509 544
 			}
510
-		}
511
-		else
545
+		} else
512 546
 		{
513 547
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514 548
 			return 0;
@@ -599,16 +633,16 @@  discard block
 block discarded – undo
599 633
 			{
600 634
 			    $height=pdf_getHeightForLogo($logo);
601 635
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
602
-			}
603
-			else
636
+			} else
604 637
 			{
605 638
 				$pdf->SetTextColor(200,0,0);
606 639
 				$pdf->SetFont('','B', $default_font_size - 2);
607 640
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608 641
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609 642
 			}
643
+		} else {
644
+		    $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
610 645
 		}
611
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612 646
 
613 647
 		$pdf->SetFont('','B', $default_font_size + 3);
614 648
 		$pdf->SetXY($posx,$posy);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/doc/pdf_beluga.modules.php 3 patches
Indentation   +583 added lines, -583 removed lines patch added patch discarded remove patch
@@ -54,128 +54,128 @@  discard block
 block discarded – undo
54 54
 
55 55
 class pdf_beluga extends ModelePDFProjects
56 56
 {
57
-	/**
58
-	 * Issuer
59
-	 * @var Societe
60
-	 */
61
-	public $emetteur;
62
-
63
-	/**
64
-	 *	Constructor
65
-	 *
66
-	 *  @param		DoliDB		$db      Database handler
67
-	 */
68
-	function __construct($db)
69
-	{
70
-		global $conf,$langs,$mysoc;
71
-
72
-		// Translations
73
-		$langs->loadLangs(array("main", "projects", "companies"));
74
-
75
-		$this->db = $db;
76
-		$this->name = "beluga";
77
-		$this->description = $langs->trans("DocumentModelBeluga");
78
-
79
-		// Dimension page pour format A4
80
-		$this->type = 'pdf';
81
-		$formatarray=pdf_getFormat();
82
-		$this->page_largeur = $formatarray['width'];
83
-		$this->page_hauteur = $formatarray['height'];
84
-		$this->format = array($this->page_largeur,$this->page_hauteur);
85
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
86
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
87
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
88
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
89
-
90
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
91
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
92
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
93
-
94
-		// Recupere emmetteur
95
-		$this->emetteur=$mysoc;
96
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
97
-
98
-		// Defini position des colonnes
99
-		$this->posxref=$this->marge_gauche+1;
100
-		$this->posxdate=$this->marge_gauche+25;
101
-		$this->posxsociety=$this->marge_gauche+45;
102
-		$this->posxamountht=$this->marge_gauche+110;
103
-		$this->posxamountttc=$this->marge_gauche+135;
104
-		$this->posxstatut=$this->marge_gauche+165;
105
-		if ($this->page_largeur < 210) // To work with US executive format
106
-		{
107
-			$this->posxref-=20;
108
-			$this->posxdate-=20;
109
-			$this->posxsociete-=20;
110
-			$this->posxamountht-=20;
111
-			$this->posxamountttc-=20;
112
-			$this->posstatut-=20;
113
-		}
114
-	}
57
+    /**
58
+     * Issuer
59
+     * @var Societe
60
+     */
61
+    public $emetteur;
62
+
63
+    /**
64
+     *	Constructor
65
+     *
66
+     *  @param		DoliDB		$db      Database handler
67
+     */
68
+    function __construct($db)
69
+    {
70
+        global $conf,$langs,$mysoc;
71
+
72
+        // Translations
73
+        $langs->loadLangs(array("main", "projects", "companies"));
74
+
75
+        $this->db = $db;
76
+        $this->name = "beluga";
77
+        $this->description = $langs->trans("DocumentModelBeluga");
78
+
79
+        // Dimension page pour format A4
80
+        $this->type = 'pdf';
81
+        $formatarray=pdf_getFormat();
82
+        $this->page_largeur = $formatarray['width'];
83
+        $this->page_hauteur = $formatarray['height'];
84
+        $this->format = array($this->page_largeur,$this->page_hauteur);
85
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
86
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
87
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
88
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
89
+
90
+        $this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
91
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
92
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
93
+
94
+        // Recupere emmetteur
95
+        $this->emetteur=$mysoc;
96
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
97
+
98
+        // Defini position des colonnes
99
+        $this->posxref=$this->marge_gauche+1;
100
+        $this->posxdate=$this->marge_gauche+25;
101
+        $this->posxsociety=$this->marge_gauche+45;
102
+        $this->posxamountht=$this->marge_gauche+110;
103
+        $this->posxamountttc=$this->marge_gauche+135;
104
+        $this->posxstatut=$this->marge_gauche+165;
105
+        if ($this->page_largeur < 210) // To work with US executive format
106
+        {
107
+            $this->posxref-=20;
108
+            $this->posxdate-=20;
109
+            $this->posxsociete-=20;
110
+            $this->posxamountht-=20;
111
+            $this->posxamountttc-=20;
112
+            $this->posstatut-=20;
113
+        }
114
+    }
115 115
 
116 116
 
117 117
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
118
-	/**
119
-	 *	Fonction generant le projet sur le disque
120
-	 *
121
-	 *	@param	Project		$object   		Object project a generer
122
-	 *	@param	Translate	$outputlangs	Lang output object
123
-	 *	@return	int         				1 if OK, <=0 if KO
124
-	 */
125
-	function write_file($object,$outputlangs)
126
-	{
118
+    /**
119
+     *	Fonction generant le projet sur le disque
120
+     *
121
+     *	@param	Project		$object   		Object project a generer
122
+     *	@param	Translate	$outputlangs	Lang output object
123
+     *	@return	int         				1 if OK, <=0 if KO
124
+     */
125
+    function write_file($object,$outputlangs)
126
+    {
127 127
         // phpcs:enable
128
-		global $conf, $hookmanager, $langs, $user;
128
+        global $conf, $hookmanager, $langs, $user;
129 129
 
130 130
         $formproject=new FormProjets($this->db);
131 131
 
132
-		if (! is_object($outputlangs)) $outputlangs=$langs;
133
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
134
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
135
-
136
-		// Load traductions files requiredby by page
137
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
138
-
139
-		if ($conf->projet->dir_output)
140
-		{
141
-			//$nblignes = count($object->lines);  // This is set later with array of tasks
142
-
143
-			$objectref = dol_sanitizeFileName($object->ref);
144
-			$dir = $conf->projet->dir_output;
145
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
146
-			$file = $dir . "/" . $objectref . ".pdf";
147
-
148
-			if (! file_exists($dir))
149
-			{
150
-				if (dol_mkdir($dir) < 0)
151
-				{
152
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
153
-					return 0;
154
-				}
155
-			}
156
-
157
-			if (file_exists($dir))
158
-			{
159
-				// Add pdfgeneration hook
160
-				if (! is_object($hookmanager))
161
-				{
162
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
163
-					$hookmanager=new HookManager($this->db);
164
-				}
165
-				$hookmanager->initHooks(array('pdfgeneration'));
166
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
167
-				global $action;
168
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
169
-
170
-				// Create pdf instance
171
-				$pdf=pdf_getInstance($this->format);
172
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
173
-				$pdf->SetAutoPageBreak(1,0);
174
-
175
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
176
-		        $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
177
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
178
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
132
+        if (! is_object($outputlangs)) $outputlangs=$langs;
133
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
134
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
135
+
136
+        // Load traductions files requiredby by page
137
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
138
+
139
+        if ($conf->projet->dir_output)
140
+        {
141
+            //$nblignes = count($object->lines);  // This is set later with array of tasks
142
+
143
+            $objectref = dol_sanitizeFileName($object->ref);
144
+            $dir = $conf->projet->dir_output;
145
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
146
+            $file = $dir . "/" . $objectref . ".pdf";
147
+
148
+            if (! file_exists($dir))
149
+            {
150
+                if (dol_mkdir($dir) < 0)
151
+                {
152
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
153
+                    return 0;
154
+                }
155
+            }
156
+
157
+            if (file_exists($dir))
158
+            {
159
+                // Add pdfgeneration hook
160
+                if (! is_object($hookmanager))
161
+                {
162
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
163
+                    $hookmanager=new HookManager($this->db);
164
+                }
165
+                $hookmanager->initHooks(array('pdfgeneration'));
166
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
167
+                global $action;
168
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
169
+
170
+                // Create pdf instance
171
+                $pdf=pdf_getInstance($this->format);
172
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
173
+                $pdf->SetAutoPageBreak(1,0);
174
+
175
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
176
+                $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
177
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
178
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
179 179
 
180 180
                 if (class_exists('TCPDF'))
181 181
                 {
@@ -190,187 +190,187 @@  discard block
 block discarded – undo
190 190
                     $tplidx = $pdf->importPage(1);
191 191
                 }
192 192
 
193
-				// Complete object by loading several other informations
194
-				$task = new Task($this->db);
195
-				$tasksarray = array();
196
-				$tasksarray = $task->getTasksArray(0, 0, $object->id);
197
-
198
-				// Special case when used with object = specimen, we may return all lines
199
-				if (! $object->id > 0) {
200
-					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
201
-				}
202
-
203
-				$object->lines=$tasksarray;
204
-				$nblignes=count($object->lines);
205
-
206
-				$pdf->Open();
207
-				$pagenb=0;
208
-				$pdf->SetDrawColor(128,128,128);
209
-
210
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
211
-				$pdf->SetSubject($outputlangs->transnoentities("Project"));
212
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
213
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
214
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
215
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
216
-
217
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
218
-
219
-				// New page
220
-				$pdf->AddPage();
221
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
222
-				$pagenb++;
223
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
224
-				$pdf->SetFont('','', $default_font_size - 1);
225
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
226
-				$pdf->SetTextColor(0,0,0);
227
-
228
-				$tab_top = 50;
229
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
230
-				$tab_height = 170;
231
-				$tab_height_newpage = 190;
232
-
233
-				// Show public note
234
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
235
-				if ($notetoshow)
236
-				{
237
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
238
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
239
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
240
-
241
-					$tab_top -= 2;
242
-
243
-					$pdf->SetFont('','', $default_font_size - 1);
244
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
245
-					$nexY = $pdf->GetY();
246
-					$height_note=$nexY-$tab_top;
247
-
248
-					// Rect prend une longueur en 3eme param
249
-					$pdf->SetDrawColor(192,192,192);
250
-					$pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
251
-
252
-					$tab_height = $tab_height - $height_note;
253
-					$tab_top = $nexY+6;
254
-				}
255
-				else
256
-				{
257
-					$height_note=0;
258
-				}
259
-
260
-				$heightoftitleline = 10;
261
-				$iniY = $tab_top + $heightoftitleline + 1;
262
-				$curY = $tab_top + $heightoftitleline + 1;
263
-				$nexY = $tab_top + $heightoftitleline + 1;
193
+                // Complete object by loading several other informations
194
+                $task = new Task($this->db);
195
+                $tasksarray = array();
196
+                $tasksarray = $task->getTasksArray(0, 0, $object->id);
197
+
198
+                // Special case when used with object = specimen, we may return all lines
199
+                if (! $object->id > 0) {
200
+                    $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
201
+                }
202
+
203
+                $object->lines=$tasksarray;
204
+                $nblignes=count($object->lines);
205
+
206
+                $pdf->Open();
207
+                $pagenb=0;
208
+                $pdf->SetDrawColor(128,128,128);
209
+
210
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
211
+                $pdf->SetSubject($outputlangs->transnoentities("Project"));
212
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
213
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
214
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
215
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
216
+
217
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
218
+
219
+                // New page
220
+                $pdf->AddPage();
221
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
222
+                $pagenb++;
223
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
224
+                $pdf->SetFont('','', $default_font_size - 1);
225
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
226
+                $pdf->SetTextColor(0,0,0);
227
+
228
+                $tab_top = 50;
229
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
230
+                $tab_height = 170;
231
+                $tab_height_newpage = 190;
232
+
233
+                // Show public note
234
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
235
+                if ($notetoshow)
236
+                {
237
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
238
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
239
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
240
+
241
+                    $tab_top -= 2;
242
+
243
+                    $pdf->SetFont('','', $default_font_size - 1);
244
+                    $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
245
+                    $nexY = $pdf->GetY();
246
+                    $height_note=$nexY-$tab_top;
247
+
248
+                    // Rect prend une longueur en 3eme param
249
+                    $pdf->SetDrawColor(192,192,192);
250
+                    $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
251
+
252
+                    $tab_height = $tab_height - $height_note;
253
+                    $tab_top = $nexY+6;
254
+                }
255
+                else
256
+                {
257
+                    $height_note=0;
258
+                }
259
+
260
+                $heightoftitleline = 10;
261
+                $iniY = $tab_top + $heightoftitleline + 1;
262
+                $curY = $tab_top + $heightoftitleline + 1;
263
+                $nexY = $tab_top + $heightoftitleline + 1;
264 264
 
265 265
                 $listofreferent=array(
266 266
                     'propal'=>array(
267
-                    	'name'=>"Proposals",
268
-                    	'title'=>"ListProposalsAssociatedProject",
269
-                    	'class'=>'Propal',
270
-                    	'table'=>'propal',
267
+                        'name'=>"Proposals",
268
+                        'title'=>"ListProposalsAssociatedProject",
269
+                        'class'=>'Propal',
270
+                        'table'=>'propal',
271 271
                         'datefieldname'=>'datep',
272
-                    	'test'=>$conf->propal->enabled && $user->rights->propale->lire,
272
+                        'test'=>$conf->propal->enabled && $user->rights->propale->lire,
273 273
                         'lang'=>'propal'),
274 274
                     'order'=>array(
275
-                    	'name'=>"CustomersOrders",
276
-                    	'title'=>"ListOrdersAssociatedProject",
277
-                    	'class'=>'Commande',
278
-                    	'table'=>'commande',
279
-                    	'datefieldname'=>'date_commande',
280
-                    	'test'=>$conf->commande->enabled && $user->rights->commande->lire,
275
+                        'name'=>"CustomersOrders",
276
+                        'title'=>"ListOrdersAssociatedProject",
277
+                        'class'=>'Commande',
278
+                        'table'=>'commande',
279
+                        'datefieldname'=>'date_commande',
280
+                        'test'=>$conf->commande->enabled && $user->rights->commande->lire,
281 281
                         'lang'=>'order'),
282 282
                     'invoice'=>array(
283
-                    	'name'=>"CustomersInvoices",
284
-                    	'title'=>"ListInvoicesAssociatedProject",
285
-                    	'class'=>'Facture',
286
-                    	'margin'=>'add',
287
-                    	'table'=>'facture',
288
-                    	'datefieldname'=>'datef',
289
-                    	'test'=>$conf->facture->enabled && $user->rights->facture->lire,
283
+                        'name'=>"CustomersInvoices",
284
+                        'title'=>"ListInvoicesAssociatedProject",
285
+                        'class'=>'Facture',
286
+                        'margin'=>'add',
287
+                        'table'=>'facture',
288
+                        'datefieldname'=>'datef',
289
+                        'test'=>$conf->facture->enabled && $user->rights->facture->lire,
290 290
                         'lang'=>'bills'),
291 291
                     'invoice_predefined'=>array(
292
-                    	'name'=>"PredefinedInvoices",
293
-                    	'title'=>"ListPredefinedInvoicesAssociatedProject",
294
-                    	'class'=>'FactureRec',
295
-                    	'table'=>'facture_rec',
296
-                    	'datefieldname'=>'datec',
297
-                    	'test'=>$conf->facture->enabled && $user->rights->facture->lire,
292
+                        'name'=>"PredefinedInvoices",
293
+                        'title'=>"ListPredefinedInvoicesAssociatedProject",
294
+                        'class'=>'FactureRec',
295
+                        'table'=>'facture_rec',
296
+                        'datefieldname'=>'datec',
297
+                        'test'=>$conf->facture->enabled && $user->rights->facture->lire,
298 298
                         'lang'=>'bills'),
299 299
                     'order_supplier'=>array(
300
-                    	'name'=>"SuppliersOrders",
301
-                    	'title'=>"ListSupplierOrdersAssociatedProject",
302
-                    	'class'=>'CommandeFournisseur',
303
-                    	'table'=>'commande_fournisseur',
304
-                    	'datefieldname'=>'date_commande',
305
-                    	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
300
+                        'name'=>"SuppliersOrders",
301
+                        'title'=>"ListSupplierOrdersAssociatedProject",
302
+                        'class'=>'CommandeFournisseur',
303
+                        'table'=>'commande_fournisseur',
304
+                        'datefieldname'=>'date_commande',
305
+                        'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
306 306
                         'lang'=>'orders'),
307 307
                     'invoice_supplier'=>array(
308
-                    	'name'=>"BillsSuppliers",
309
-                    	'title'=>"ListSupplierInvoicesAssociatedProject",
310
-                    	'class'=>'FactureFournisseur',
311
-                    	'margin'=>'minus',
312
-                    	'table'=>'facture_fourn',
313
-                    	'datefieldname'=>'datef',
314
-                    	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
308
+                        'name'=>"BillsSuppliers",
309
+                        'title'=>"ListSupplierInvoicesAssociatedProject",
310
+                        'class'=>'FactureFournisseur',
311
+                        'margin'=>'minus',
312
+                        'table'=>'facture_fourn',
313
+                        'datefieldname'=>'datef',
314
+                        'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
315 315
                         'lang'=>'bills'),
316 316
                     'contract'=>array(
317
-                    	'name'=>"Contracts",
318
-                    	'title'=>"ListContractAssociatedProject",
319
-                    	'class'=>'Contrat',
320
-                    	'table'=>'contrat',
321
-                    	'datefieldname'=>'date_contrat',
322
-                    	'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
317
+                        'name'=>"Contracts",
318
+                        'title'=>"ListContractAssociatedProject",
319
+                        'class'=>'Contrat',
320
+                        'table'=>'contrat',
321
+                        'datefieldname'=>'date_contrat',
322
+                        'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
323 323
                         'lang'=>'contract'),
324 324
                     'intervention'=>array(
325
-                    	'name'=>"Interventions",
326
-                    	'title'=>"ListFichinterAssociatedProject",
327
-                    	'class'=>'Fichinter',
328
-                    	'table'=>'fichinter',
329
-                    	'datefieldname'=>'date_valid',
330
-                    	'disableamount'=>1,
331
-                    	'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
325
+                        'name'=>"Interventions",
326
+                        'title'=>"ListFichinterAssociatedProject",
327
+                        'class'=>'Fichinter',
328
+                        'table'=>'fichinter',
329
+                        'datefieldname'=>'date_valid',
330
+                        'disableamount'=>1,
331
+                        'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
332 332
                         'lang'=>'interventions'),
333 333
                     'trip'=>array(
334
-                    	'name'=>"TripsAndExpenses",
335
-                    	'title'=>"ListExpenseReportsAssociatedProject",
336
-                    	'class'=>'Deplacement',
337
-                    	'table'=>'deplacement',
338
-                    	'datefieldname'=>'dated',
339
-                    	'margin'=>'minus',
340
-                    	'disableamount'=>1,
341
-                    	'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
334
+                        'name'=>"TripsAndExpenses",
335
+                        'title'=>"ListExpenseReportsAssociatedProject",
336
+                        'class'=>'Deplacement',
337
+                        'table'=>'deplacement',
338
+                        'datefieldname'=>'dated',
339
+                        'margin'=>'minus',
340
+                        'disableamount'=>1,
341
+                        'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
342 342
                         'lang'=>'trip'),
343 343
                     'expensereport'=>array(
344
-                    	'name'=>"ExpensesReports",
345
-                    	'title'=>"ListExpenseReportsAssociatedProject",
346
-                    	'class'=>'ExpenseReport',
347
-                    	'table'=>'expensereport',
348
-                    	'datefieldname'=>'dated',
349
-                    	'margin'=>'minus',
350
-                    	'disableamount'=>1,
351
-                    	'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
344
+                        'name'=>"ExpensesReports",
345
+                        'title'=>"ListExpenseReportsAssociatedProject",
346
+                        'class'=>'ExpenseReport',
347
+                        'table'=>'expensereport',
348
+                        'datefieldname'=>'dated',
349
+                        'margin'=>'minus',
350
+                        'disableamount'=>1,
351
+                        'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
352 352
                         'lang'=>'trip'),
353 353
                     'agenda'=>array(
354
-                    	'name'=>"Agenda",
355
-                    	'title'=>"ListActionsAssociatedProject",
356
-                    	'class'=>'ActionComm',
357
-                    	'table'=>'actioncomm',
358
-                    	'datefieldname'=>'datep',
359
-                    	'disableamount'=>1,
360
-                    	'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
354
+                        'name'=>"Agenda",
355
+                        'title'=>"ListActionsAssociatedProject",
356
+                        'class'=>'ActionComm',
357
+                        'table'=>'actioncomm',
358
+                        'datefieldname'=>'datep',
359
+                        'disableamount'=>1,
360
+                        'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
361 361
                         'lang'=>'agenda')
362 362
                 );
363 363
 
364 364
 
365 365
                 foreach ($listofreferent as $key => $value)
366 366
                 {
367
-                	$title=$value['title'];
368
-                	$classname=$value['class'];
369
-                	$tablename=$value['table'];
370
-                	$datefieldname=$value['datefieldname'];
371
-                	$qualified=$value['test'];
372
-                	$langstoload=$value['lang'];
373
-                	$langs->load($langstoload);
367
+                    $title=$value['title'];
368
+                    $classname=$value['class'];
369
+                    $tablename=$value['table'];
370
+                    $datefieldname=$value['datefieldname'];
371
+                    $qualified=$value['test'];
372
+                    $langstoload=$value['lang'];
373
+                    $langs->load($langstoload);
374 374
 
375 375
                     if (! $qualified) continue;
376 376
 
@@ -425,26 +425,26 @@  discard block
 block discarded – undo
425 425
                             $total_ttc = 0;
426 426
                             $num = count($elementarray);
427 427
 
428
-				// Loop on each lines
429
-				for ($i = 0; $i < $num; $i ++)
430
-				{
431
-					$curY = $nexY;
432
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
433
-					$pdf->SetTextColor(0,0,0);
434
-
435
-					$pdf->setTopMargin($tab_top_newpage);
436
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
437
-					$pageposbefore=$pdf->getPage();
438
-
439
-					// Description of line
440
-					$idofelement=$elementarray[$i];
441
-                             	if ($classname == 'ExpenseReport')
442
-                               	{
443
-                               		// We get id of expense report
444
-                               		$expensereportline=new ExpenseReportLine($this->db);
445
-                               		$expensereportline->fetch($idofelement);
446
-                               		$idofelement = $expensereportline->fk_expensereport;
447
-                               	}
428
+                // Loop on each lines
429
+                for ($i = 0; $i < $num; $i ++)
430
+                {
431
+                    $curY = $nexY;
432
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
433
+                    $pdf->SetTextColor(0,0,0);
434
+
435
+                    $pdf->setTopMargin($tab_top_newpage);
436
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
437
+                    $pageposbefore=$pdf->getPage();
438
+
439
+                    // Description of line
440
+                    $idofelement=$elementarray[$i];
441
+                                    if ($classname == 'ExpenseReport')
442
+                                    {
443
+                                        // We get id of expense report
444
+                                        $expensereportline=new ExpenseReportLine($this->db);
445
+                                        $expensereportline->fetch($idofelement);
446
+                                        $idofelement = $expensereportline->fk_expensereport;
447
+                                    }
448 448
 
449 449
                                 $element = new $classname($this->db);
450 450
                                 $element->fetch($idofelement);
@@ -457,114 +457,114 @@  discard block
 block discarded – undo
457 457
                                         $qualifiedfortotal = false; // Replacement invoice
458 458
                                 }
459 459
 
460
-					$showpricebeforepagebreak=1;
461
-
462
-					$pdf->startTransaction();
463
-					// Label
464
-					$pdf->SetXY($this->posxref, $curY);
465
-					$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
466
-					$pageposafter=$pdf->getPage();
467
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
468
-					{
469
-						$pdf->rollbackTransaction(true);
470
-						$pageposafter=$pageposbefore;
471
-						//print $pageposafter.'-'.$pageposbefore;exit;
472
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
473
-						// Label
474
-						$pdf->SetXY($this->posxref, $curY);
475
-						$posybefore=$pdf->GetY();
476
-						$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
477
-						$pageposafter=$pdf->getPage();
478
-						$posyafter=$pdf->GetY();
479
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
480
-						{
481
-							if ($i == ($num-1))	// No more lines, and no space left to show total, so we create a new page
482
-							{
483
-								$pdf->AddPage('','',true);
484
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
486
-								$pdf->setPage($pageposafter+1);
487
-							}
488
-						}
489
-						else
490
-						{
491
-							// We found a page break
492
-							$showpricebeforepagebreak=0;
493
-							$forcedesconsamepage=1;
494
-							if ($forcedesconsamepage)
495
-							{
496
-								$pdf->rollbackTransaction(true);
497
-								$pageposafter=$pageposbefore;
498
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
499
-
500
-								$pdf->AddPage('','',true);
501
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
502
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
503
-								$pdf->setPage($pageposafter+1);
504
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
505
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
506
-								$pdf->SetTextColor(0,0,0);
507
-
508
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
509
-								$curY = $tab_top_newpage + $heightoftitleline + 1;
510
-
511
-								// Label
512
-								$pdf->SetXY($this->posxref, $curY);
513
-								$posybefore=$pdf->GetY();
514
-								$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
515
-								$pageposafter=$pdf->getPage();
516
-								$posyafter=$pdf->GetY();
517
-							}
518
-						}
519
-						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
520
-					}
521
-					else	// No pagebreak
522
-					{
523
-						$pdf->commitTransaction();
524
-					}
525
-					$posYAfterDescription=$pdf->GetY();
526
-
527
-					$nexY = $pdf->GetY();
528
-					$pageposafter=$pdf->getPage();
529
-					$pdf->setPage($pageposbefore);
530
-					$pdf->setTopMargin($this->marge_haute);
531
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
532
-
533
-					// We suppose that a too long description is moved completely on next page
534
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
535
-						//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
536
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
537
-					}
538
-
539
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
540
-
541
-					// Date
542
-					if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
543
-						$date = $element->date_commande;
544
-					else {
545
-						$date = $element->date;
546
-						if (empty($date))
547
-							$date = $element->datep;
548
-						if (empty($date))
549
-							$date = $element->date_contrat;
550
-						if (empty($date))
551
-							$date = $element->datev; // Fiche inter
552
-					}
553
-
554
-					$pdf->SetXY($this->posxdate, $curY);
555
-					$pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
556
-
557
-					$pdf->SetXY($this->posxsociety, $curY);
558
-					if ($classname == 'ExpenseReport')
559
-					{
560
-						$fuser=new User($this->db);
561
-						$fuser->fetch($element->fk_user_author);
562
-						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
563
-					}
564
-					else
565
-					{
566
-						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L');
567
-					}
460
+                    $showpricebeforepagebreak=1;
461
+
462
+                    $pdf->startTransaction();
463
+                    // Label
464
+                    $pdf->SetXY($this->posxref, $curY);
465
+                    $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
466
+                    $pageposafter=$pdf->getPage();
467
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
468
+                    {
469
+                        $pdf->rollbackTransaction(true);
470
+                        $pageposafter=$pageposbefore;
471
+                        //print $pageposafter.'-'.$pageposbefore;exit;
472
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
473
+                        // Label
474
+                        $pdf->SetXY($this->posxref, $curY);
475
+                        $posybefore=$pdf->GetY();
476
+                        $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
477
+                        $pageposafter=$pdf->getPage();
478
+                        $posyafter=$pdf->GetY();
479
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
480
+                        {
481
+                            if ($i == ($num-1))	// No more lines, and no space left to show total, so we create a new page
482
+                            {
483
+                                $pdf->AddPage('','',true);
484
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
486
+                                $pdf->setPage($pageposafter+1);
487
+                            }
488
+                        }
489
+                        else
490
+                        {
491
+                            // We found a page break
492
+                            $showpricebeforepagebreak=0;
493
+                            $forcedesconsamepage=1;
494
+                            if ($forcedesconsamepage)
495
+                            {
496
+                                $pdf->rollbackTransaction(true);
497
+                                $pageposafter=$pageposbefore;
498
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
499
+
500
+                                $pdf->AddPage('','',true);
501
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
502
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
503
+                                $pdf->setPage($pageposafter+1);
504
+                                $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
505
+                                $pdf->MultiCell(0, 3, '');		// Set interline to 3
506
+                                $pdf->SetTextColor(0,0,0);
507
+
508
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
509
+                                $curY = $tab_top_newpage + $heightoftitleline + 1;
510
+
511
+                                // Label
512
+                                $pdf->SetXY($this->posxref, $curY);
513
+                                $posybefore=$pdf->GetY();
514
+                                $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
515
+                                $pageposafter=$pdf->getPage();
516
+                                $posyafter=$pdf->GetY();
517
+                            }
518
+                        }
519
+                        //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
520
+                    }
521
+                    else	// No pagebreak
522
+                    {
523
+                        $pdf->commitTransaction();
524
+                    }
525
+                    $posYAfterDescription=$pdf->GetY();
526
+
527
+                    $nexY = $pdf->GetY();
528
+                    $pageposafter=$pdf->getPage();
529
+                    $pdf->setPage($pageposbefore);
530
+                    $pdf->setTopMargin($this->marge_haute);
531
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
532
+
533
+                    // We suppose that a too long description is moved completely on next page
534
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
535
+                        //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
536
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
537
+                    }
538
+
539
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
540
+
541
+                    // Date
542
+                    if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
543
+                        $date = $element->date_commande;
544
+                    else {
545
+                        $date = $element->date;
546
+                        if (empty($date))
547
+                            $date = $element->datep;
548
+                        if (empty($date))
549
+                            $date = $element->date_contrat;
550
+                        if (empty($date))
551
+                            $date = $element->datev; // Fiche inter
552
+                    }
553
+
554
+                    $pdf->SetXY($this->posxdate, $curY);
555
+                    $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
556
+
557
+                    $pdf->SetXY($this->posxsociety, $curY);
558
+                    if ($classname == 'ExpenseReport')
559
+                    {
560
+                        $fuser=new User($this->db);
561
+                        $fuser->fetch($element->fk_user_author);
562
+                        $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
563
+                    }
564
+                    else
565
+                    {
566
+                        $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L');
567
+                    }
568 568
 
569 569
                                 // Amount without tax
570 570
                                 if (empty($value['disableamount'])) {
@@ -573,16 +573,16 @@  discard block
 block discarded – undo
573 573
                                     $pdf->SetXY($this->posxamountttc, $curY);
574 574
                                     $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : '&nbsp;'), 1, 'R');
575 575
                                 } else {
576
-                                	$pdf->SetXY($this->posxamountht, $curY);
577
-                                	if ($key == 'agenda')
578
-                                	{
579
-                                		$textforamount = dol_trunc($element->label, 26);
580
-                                		$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L');
581
-                                	}
582
-                                	else
583
-                                	{
584
-	                                    $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
585
-                                	}
576
+                                    $pdf->SetXY($this->posxamountht, $curY);
577
+                                    if ($key == 'agenda')
578
+                                    {
579
+                                        $textforamount = dol_trunc($element->label, 26);
580
+                                        $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L');
581
+                                    }
582
+                                    else
583
+                                    {
584
+                                        $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
585
+                                    }
586 586
                                 }
587 587
 
588 588
                                 // Status
@@ -619,187 +619,187 @@  discard block
 block discarded – undo
619 619
                         }
620 620
                     }
621 621
 
622
-					$nexY+=2;    // Passe espace entre les lignes
623
-
624
-					// Detect if some page were added automatically and output _tableau for past pages
625
-					while ($pagenb < $pageposafter)
626
-					{
627
-						$pdf->setPage($pagenb);
628
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
629
-						$pagenb++;
630
-						$pdf->setPage($pagenb);
631
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
632
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
633
-					}
634
-				}
635
-
636
-				// Pied de page
637
-				$this->_pagefoot($pdf, $object, $outputlangs);
638
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
639
-
640
-				$pdf->Close();
641
-
642
-				$pdf->Output($file, 'F');
643
-
644
-				// Add pdfgeneration hook
645
-				$hookmanager->initHooks(array('pdfgeneration'));
646
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
647
-				global $action;
648
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
649
-
650
-				if (! empty($conf->global->MAIN_UMASK))
651
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
652
-
653
-				$this->result = array('fullpath'=>$file);
654
-
655
-				return 1;   // Pas d'erreur
656
-			}
657
-			else
658
-			{
659
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
660
-				return 0;
661
-			}
662
-		}
663
-		else
664
-		{
665
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
666
-			return 0;
667
-		}
668
-	}
669
-
670
-
671
-	/**
672
-	 *   Show table for lines
673
-	 *
674
-	 *   @param		PDF			$pdf     		Object PDF
675
-	 *   @param		string		$tab_top		Top position of table
676
-	 *   @param		string		$tab_height		Height of table (rectangle)
677
-	 *   @param		int			$nexY			Y
678
-	 *   @param		Translate	$outputlangs	Langs object
679
-	 *   @param		int			$hidetop		Hide top bar of array
680
-	 *   @param		int			$hidebottom		Hide bottom bar of array
681
-	 *   @return	void
682
-	 */
683
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
684
-	{
685
-		global $conf,$mysoc;
686
-
687
-		$heightoftitleline = 10;
688
-
689
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
690
-
691
-		$pdf->SetDrawColor(128,128,128);
692
-
693
-		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
694
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
695
-
696
-		// line prend une position y en 3eme param
697
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
698
-
699
-		$pdf->SetTextColor(0,0,0);
700
-		$pdf->SetFont('','', $default_font_size);
701
-
702
-		$pdf->SetXY($this->posxref, $tab_top+1);
703
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
704
-
705
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
706
-		$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
707
-
708
-		$pdf->SetXY($this->posxworkload, $tab_top+1);
709
-		$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
710
-
711
-		$pdf->SetXY($this->posxprogress, $tab_top+1);
712
-		$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
713
-
714
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
715
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
716
-
717
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
718
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
719
-	}
720
-
721
-	/**
722
-	 *  Show top header of page.
723
-	 *
724
-	 *  @param	PDF			$pdf     		Object PDF
725
-	 *  @param  Project		$object     	Object to show
726
-	 *  @param  int	    	$showaddress    0=no, 1=yes
727
-	 *  @param  Translate	$outputlangs	Object lang for output
728
-	 *  @return	void
729
-	 */
730
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
731
-	{
732
-		global $langs,$conf,$mysoc;
733
-
734
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
622
+                    $nexY+=2;    // Passe espace entre les lignes
623
+
624
+                    // Detect if some page were added automatically and output _tableau for past pages
625
+                    while ($pagenb < $pageposafter)
626
+                    {
627
+                        $pdf->setPage($pagenb);
628
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
629
+                        $pagenb++;
630
+                        $pdf->setPage($pagenb);
631
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
632
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
633
+                    }
634
+                }
635
+
636
+                // Pied de page
637
+                $this->_pagefoot($pdf, $object, $outputlangs);
638
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
639
+
640
+                $pdf->Close();
641
+
642
+                $pdf->Output($file, 'F');
643
+
644
+                // Add pdfgeneration hook
645
+                $hookmanager->initHooks(array('pdfgeneration'));
646
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
647
+                global $action;
648
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
649
+
650
+                if (! empty($conf->global->MAIN_UMASK))
651
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
652
+
653
+                $this->result = array('fullpath'=>$file);
654
+
655
+                return 1;   // Pas d'erreur
656
+            }
657
+            else
658
+            {
659
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
660
+                return 0;
661
+            }
662
+        }
663
+        else
664
+        {
665
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
666
+            return 0;
667
+        }
668
+    }
669
+
670
+
671
+    /**
672
+     *   Show table for lines
673
+     *
674
+     *   @param		PDF			$pdf     		Object PDF
675
+     *   @param		string		$tab_top		Top position of table
676
+     *   @param		string		$tab_height		Height of table (rectangle)
677
+     *   @param		int			$nexY			Y
678
+     *   @param		Translate	$outputlangs	Langs object
679
+     *   @param		int			$hidetop		Hide top bar of array
680
+     *   @param		int			$hidebottom		Hide bottom bar of array
681
+     *   @return	void
682
+     */
683
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
684
+    {
685
+        global $conf,$mysoc;
686
+
687
+        $heightoftitleline = 10;
688
+
689
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
690
+
691
+        $pdf->SetDrawColor(128,128,128);
692
+
693
+        // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
694
+        $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
695
+
696
+        // line prend une position y en 3eme param
697
+        $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
698
+
699
+        $pdf->SetTextColor(0,0,0);
700
+        $pdf->SetFont('','', $default_font_size);
701
+
702
+        $pdf->SetXY($this->posxref, $tab_top+1);
703
+        $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
704
+
705
+        $pdf->SetXY($this->posxlabel, $tab_top+1);
706
+        $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
707
+
708
+        $pdf->SetXY($this->posxworkload, $tab_top+1);
709
+        $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
710
+
711
+        $pdf->SetXY($this->posxprogress, $tab_top+1);
712
+        $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
713
+
714
+        $pdf->SetXY($this->posxdatestart, $tab_top+1);
715
+        $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
716
+
717
+        $pdf->SetXY($this->posxdateend, $tab_top+1);
718
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
719
+    }
720
+
721
+    /**
722
+     *  Show top header of page.
723
+     *
724
+     *  @param	PDF			$pdf     		Object PDF
725
+     *  @param  Project		$object     	Object to show
726
+     *  @param  int	    	$showaddress    0=no, 1=yes
727
+     *  @param  Translate	$outputlangs	Object lang for output
728
+     *  @return	void
729
+     */
730
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
731
+    {
732
+        global $langs,$conf,$mysoc;
733
+
734
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
735
+
736
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
735 737
 
736
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
737
-
738
-		$pdf->SetTextColor(0,0,60);
739
-		$pdf->SetFont('','B', $default_font_size + 3);
738
+        $pdf->SetTextColor(0,0,60);
739
+        $pdf->SetFont('','B', $default_font_size + 3);
740 740
 
741 741
         $posx=$this->page_largeur-$this->marge_droite-100;
742
-		$posy=$this->marge_haute;
743
-
744
-		$pdf->SetXY($this->marge_gauche,$posy);
745
-
746
-		// Logo
747
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
748
-		if ($mysoc->logo)
749
-		{
750
-			if (is_readable($logo))
751
-			{
752
-			    $height=pdf_getHeightForLogo($logo);
753
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
754
-			}
755
-			else
756
-			{
757
-				$pdf->SetTextColor(200,0,0);
758
-				$pdf->SetFont('','B', $default_font_size - 2);
759
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
760
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
761
-			}
762
-		}
763
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
764
-
765
-		$pdf->SetFont('','B', $default_font_size + 3);
766
-		$pdf->SetXY($posx,$posy);
767
-		$pdf->SetTextColor(0,0,60);
768
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
769
-		$pdf->SetFont('','', $default_font_size + 2);
770
-
771
-		$posy+=6;
772
-		$pdf->SetXY($posx,$posy);
773
-		$pdf->SetTextColor(0,0,60);
774
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
775
-
776
-		$posy+=6;
777
-		$pdf->SetXY($posx,$posy);
778
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
779
-
780
-		if (is_object($object->thirdparty))
781
-		{
782
-			$posy+=6;
783
-			$pdf->SetXY($posx,$posy);
784
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
785
-		}
786
-
787
-		$pdf->SetTextColor(0,0,60);
788
-	}
789
-
790
-	/**
791
-	 *   	Show footer of page. Need this->emetteur object
742
+        $posy=$this->marge_haute;
743
+
744
+        $pdf->SetXY($this->marge_gauche,$posy);
745
+
746
+        // Logo
747
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
748
+        if ($mysoc->logo)
749
+        {
750
+            if (is_readable($logo))
751
+            {
752
+                $height=pdf_getHeightForLogo($logo);
753
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
754
+            }
755
+            else
756
+            {
757
+                $pdf->SetTextColor(200,0,0);
758
+                $pdf->SetFont('','B', $default_font_size - 2);
759
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
760
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
761
+            }
762
+        }
763
+        else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
764
+
765
+        $pdf->SetFont('','B', $default_font_size + 3);
766
+        $pdf->SetXY($posx,$posy);
767
+        $pdf->SetTextColor(0,0,60);
768
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
769
+        $pdf->SetFont('','', $default_font_size + 2);
770
+
771
+        $posy+=6;
772
+        $pdf->SetXY($posx,$posy);
773
+        $pdf->SetTextColor(0,0,60);
774
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
775
+
776
+        $posy+=6;
777
+        $pdf->SetXY($posx,$posy);
778
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
779
+
780
+        if (is_object($object->thirdparty))
781
+        {
782
+            $posy+=6;
783
+            $pdf->SetXY($posx,$posy);
784
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
785
+        }
786
+
787
+        $pdf->SetTextColor(0,0,60);
788
+    }
789
+
790
+    /**
791
+     *   	Show footer of page. Need this->emetteur object
792 792
      *
793
-	 *   	@param	PDF			$pdf     			PDF
794
-	 * 		@param	Project		$object				Object to show
795
-	 *      @param	Translate	$outputlangs		Object lang for output
796
-	 *      @param	int			$hidefreetext		1=Hide free text
797
-	 *      @return	integer
798
-	 */
799
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
800
-	{
801
-		global $conf;
802
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
803
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
804
-	}
793
+     *   	@param	PDF			$pdf     			PDF
794
+     * 		@param	Project		$object				Object to show
795
+     *      @param	Translate	$outputlangs		Object lang for output
796
+     *      @param	int			$hidefreetext		1=Hide free text
797
+     *      @return	integer
798
+     */
799
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
800
+    {
801
+        global $conf;
802
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
803
+        return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
804
+    }
805 805
 }
Please login to merge, or discard this patch.
Spacing   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 35
 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
36 36
 
37
-if (! empty($conf->propal->enabled))        require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
38
-if (! empty($conf->facture->enabled))       require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
39
-if (! empty($conf->facture->enabled))       require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
40
-if (! empty($conf->commande->enabled))      require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
41
-if (! empty($conf->fournisseur->enabled))   require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
42
-if (! empty($conf->fournisseur->enabled))   require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
43
-if (! empty($conf->contrat->enabled))       require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
44
-if (! empty($conf->ficheinter->enabled))    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
45
-if (! empty($conf->deplacement->enabled))   require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
46
-if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
47
-if (! empty($conf->agenda->enabled))        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
37
+if (!empty($conf->propal->enabled))        require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
38
+if (!empty($conf->facture->enabled))       require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
39
+if (!empty($conf->facture->enabled))       require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
40
+if (!empty($conf->commande->enabled))      require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
41
+if (!empty($conf->fournisseur->enabled))   require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
42
+if (!empty($conf->fournisseur->enabled))   require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
43
+if (!empty($conf->contrat->enabled))       require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
44
+if (!empty($conf->ficheinter->enabled))    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
45
+if (!empty($conf->deplacement->enabled))   require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
46
+if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
47
+if (!empty($conf->agenda->enabled))        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
48 48
 
49 49
 
50 50
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	function __construct($db)
69 69
 	{
70
-		global $conf,$langs,$mysoc;
70
+		global $conf, $langs, $mysoc;
71 71
 
72 72
 		// Translations
73 73
 		$langs->loadLangs(array("main", "projects", "companies"));
@@ -78,38 +78,38 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// Dimension page pour format A4
80 80
 		$this->type = 'pdf';
81
-		$formatarray=pdf_getFormat();
81
+		$formatarray = pdf_getFormat();
82 82
 		$this->page_largeur = $formatarray['width'];
83 83
 		$this->page_hauteur = $formatarray['height'];
84
-		$this->format = array($this->page_largeur,$this->page_hauteur);
85
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
86
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
87
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
88
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
84
+		$this->format = array($this->page_largeur, $this->page_hauteur);
85
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
86
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
87
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
88
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
89 89
 
90
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
91
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
92
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
90
+		$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
91
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
92
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
93 93
 
94 94
 		// Recupere emmetteur
95
-		$this->emetteur=$mysoc;
96
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
95
+		$this->emetteur = $mysoc;
96
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
97 97
 
98 98
 		// Defini position des colonnes
99
-		$this->posxref=$this->marge_gauche+1;
100
-		$this->posxdate=$this->marge_gauche+25;
101
-		$this->posxsociety=$this->marge_gauche+45;
102
-		$this->posxamountht=$this->marge_gauche+110;
103
-		$this->posxamountttc=$this->marge_gauche+135;
104
-		$this->posxstatut=$this->marge_gauche+165;
99
+		$this->posxref = $this->marge_gauche + 1;
100
+		$this->posxdate = $this->marge_gauche + 25;
101
+		$this->posxsociety = $this->marge_gauche + 45;
102
+		$this->posxamountht = $this->marge_gauche + 110;
103
+		$this->posxamountttc = $this->marge_gauche + 135;
104
+		$this->posxstatut = $this->marge_gauche + 165;
105 105
 		if ($this->page_largeur < 210) // To work with US executive format
106 106
 		{
107
-			$this->posxref-=20;
108
-			$this->posxdate-=20;
109
-			$this->posxsociete-=20;
110
-			$this->posxamountht-=20;
111
-			$this->posxamountttc-=20;
112
-			$this->posstatut-=20;
107
+			$this->posxref -= 20;
108
+			$this->posxdate -= 20;
109
+			$this->posxsociete -= 20;
110
+			$this->posxamountht -= 20;
111
+			$this->posxamountttc -= 20;
112
+			$this->posstatut -= 20;
113 113
 		}
114 114
 	}
115 115
 
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 	 *	@param	Translate	$outputlangs	Lang output object
123 123
 	 *	@return	int         				1 if OK, <=0 if KO
124 124
 	 */
125
-	function write_file($object,$outputlangs)
125
+	function write_file($object, $outputlangs)
126 126
 	{
127 127
         // phpcs:enable
128 128
 		global $conf, $hookmanager, $langs, $user;
129 129
 
130
-        $formproject=new FormProjets($this->db);
130
+        $formproject = new FormProjets($this->db);
131 131
 
132
-		if (! is_object($outputlangs)) $outputlangs=$langs;
132
+		if (!is_object($outputlangs)) $outputlangs = $langs;
133 133
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
134
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
134
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
135 135
 
136 136
 		// Load traductions files requiredby by page
137 137
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
 
143 143
 			$objectref = dol_sanitizeFileName($object->ref);
144 144
 			$dir = $conf->projet->dir_output;
145
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
146
-			$file = $dir . "/" . $objectref . ".pdf";
145
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
146
+			$file = $dir."/".$objectref.".pdf";
147 147
 
148
-			if (! file_exists($dir))
148
+			if (!file_exists($dir))
149 149
 			{
150 150
 				if (dol_mkdir($dir) < 0)
151 151
 				{
152
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
152
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
153 153
 					return 0;
154 154
 				}
155 155
 			}
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 			if (file_exists($dir))
158 158
 			{
159 159
 				// Add pdfgeneration hook
160
-				if (! is_object($hookmanager))
160
+				if (!is_object($hookmanager))
161 161
 				{
162 162
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
163
-					$hookmanager=new HookManager($this->db);
163
+					$hookmanager = new HookManager($this->db);
164 164
 				}
165 165
 				$hookmanager->initHooks(array('pdfgeneration'));
166
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
166
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
167 167
 				global $action;
168
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
168
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
169 169
 
170 170
 				// Create pdf instance
171
-				$pdf=pdf_getInstance($this->format);
172
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
173
-				$pdf->SetAutoPageBreak(1,0);
171
+				$pdf = pdf_getInstance($this->format);
172
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
173
+				$pdf->SetAutoPageBreak(1, 0);
174 174
 
175
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
176
-		        $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
177
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
178
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
175
+				$heightforinfotot = 40; // Height reserved to output the info and total part
176
+		        $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
177
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
178
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
179 179
 
180 180
                 if (class_exists('TCPDF'))
181 181
                 {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 }
185 185
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
186 186
                 // Set path to the background PDF File
187
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
187
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
188 188
                 {
189 189
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
190 190
                     $tplidx = $pdf->importPage(1);
@@ -196,65 +196,65 @@  discard block
 block discarded – undo
196 196
 				$tasksarray = $task->getTasksArray(0, 0, $object->id);
197 197
 
198 198
 				// Special case when used with object = specimen, we may return all lines
199
-				if (! $object->id > 0) {
200
-					$tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
199
+				if (!$object->id > 0) {
200
+					$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
201 201
 				}
202 202
 
203
-				$object->lines=$tasksarray;
204
-				$nblignes=count($object->lines);
203
+				$object->lines = $tasksarray;
204
+				$nblignes = count($object->lines);
205 205
 
206 206
 				$pdf->Open();
207
-				$pagenb=0;
208
-				$pdf->SetDrawColor(128,128,128);
207
+				$pagenb = 0;
208
+				$pdf->SetDrawColor(128, 128, 128);
209 209
 
210 210
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
211 211
 				$pdf->SetSubject($outputlangs->transnoentities("Project"));
212 212
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
213 213
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
214 214
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
215
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
215
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
216 216
 
217
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
217
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
218 218
 
219 219
 				// New page
220 220
 				$pdf->AddPage();
221
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
221
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
222 222
 				$pagenb++;
223 223
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
224
-				$pdf->SetFont('','', $default_font_size - 1);
225
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
226
-				$pdf->SetTextColor(0,0,0);
224
+				$pdf->SetFont('', '', $default_font_size - 1);
225
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
226
+				$pdf->SetTextColor(0, 0, 0);
227 227
 
228 228
 				$tab_top = 50;
229
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
229
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
230 230
 				$tab_height = 170;
231 231
 				$tab_height_newpage = 190;
232 232
 
233 233
 				// Show public note
234
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
234
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
235 235
 				if ($notetoshow)
236 236
 				{
237
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
237
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
238 238
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
239 239
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
240 240
 
241 241
 					$tab_top -= 2;
242 242
 
243
-					$pdf->SetFont('','', $default_font_size - 1);
244
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
243
+					$pdf->SetFont('', '', $default_font_size - 1);
244
+					$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
245 245
 					$nexY = $pdf->GetY();
246
-					$height_note=$nexY-$tab_top;
246
+					$height_note = $nexY - $tab_top;
247 247
 
248 248
 					// Rect prend une longueur en 3eme param
249
-					$pdf->SetDrawColor(192,192,192);
250
-					$pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
249
+					$pdf->SetDrawColor(192, 192, 192);
250
+					$pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2);
251 251
 
252 252
 					$tab_height = $tab_height - $height_note;
253
-					$tab_top = $nexY+6;
253
+					$tab_top = $nexY + 6;
254 254
 				}
255 255
 				else
256 256
 				{
257
-					$height_note=0;
257
+					$height_note = 0;
258 258
 				}
259 259
 
260 260
 				$heightoftitleline = 10;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				$curY = $tab_top + $heightoftitleline + 1;
263 263
 				$nexY = $tab_top + $heightoftitleline + 1;
264 264
 
265
-                $listofreferent=array(
265
+                $listofreferent = array(
266 266
                     'propal'=>array(
267 267
                     	'name'=>"Proposals",
268 268
                     	'title'=>"ListProposalsAssociatedProject",
@@ -364,15 +364,15 @@  discard block
 block discarded – undo
364 364
 
365 365
                 foreach ($listofreferent as $key => $value)
366 366
                 {
367
-                	$title=$value['title'];
368
-                	$classname=$value['class'];
369
-                	$tablename=$value['table'];
370
-                	$datefieldname=$value['datefieldname'];
371
-                	$qualified=$value['test'];
372
-                	$langstoload=$value['lang'];
367
+                	$title = $value['title'];
368
+                	$classname = $value['class'];
369
+                	$tablename = $value['table'];
370
+                	$datefieldname = $value['datefieldname'];
371
+                	$qualified = $value['test'];
372
+                	$langstoload = $value['lang'];
373 373
                 	$langs->load($langstoload);
374 374
 
375
-                    if (! $qualified) continue;
375
+                    if (!$qualified) continue;
376 376
 
377 377
                     //var_dump("$key, $tablename, $datefieldname, $dates, $datee");
378 378
                     $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
                         $nexY = $pdf->GetY() + 5;
389 389
 
390 390
                         $curY = $nexY;
391
-                        $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
392
-                        $pdf->SetTextColor(0,0,0);
391
+                        $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
392
+                        $pdf->SetTextColor(0, 0, 0);
393 393
 
394 394
                         $pdf->SetXY($this->posxref, $curY);
395 395
                         $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
                         $pdf->SetXY($this->posxdate, $curY);
403 403
                         $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
404 404
                         $pdf->SetXY($this->posxsociety, $curY);
405
-                        $titlethirdparty=$outputlangs->transnoentities("ThirdParty");
406
-                        if ($classname == 'ExpenseReport') $titlethirdparty=$langs->trans("User");
405
+                        $titlethirdparty = $outputlangs->transnoentities("ThirdParty");
406
+                        if ($classname == 'ExpenseReport') $titlethirdparty = $langs->trans("User");
407 407
                         $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L');
408 408
                         if (empty($value['disableamount'])) {
409 409
                             $pdf->SetXY($this->posxamountht, $curY);
@@ -426,22 +426,22 @@  discard block
 block discarded – undo
426 426
                             $num = count($elementarray);
427 427
 
428 428
 				// Loop on each lines
429
-				for ($i = 0; $i < $num; $i ++)
429
+				for ($i = 0; $i < $num; $i++)
430 430
 				{
431 431
 					$curY = $nexY;
432
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
433
-					$pdf->SetTextColor(0,0,0);
432
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
433
+					$pdf->SetTextColor(0, 0, 0);
434 434
 
435 435
 					$pdf->setTopMargin($tab_top_newpage);
436
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
437
-					$pageposbefore=$pdf->getPage();
436
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
437
+					$pageposbefore = $pdf->getPage();
438 438
 
439 439
 					// Description of line
440
-					$idofelement=$elementarray[$i];
440
+					$idofelement = $elementarray[$i];
441 441
                              	if ($classname == 'ExpenseReport')
442 442
                                	{
443 443
                                		// We get id of expense report
444
-                               		$expensereportline=new ExpenseReportLine($this->db);
444
+                               		$expensereportline = new ExpenseReportLine($this->db);
445 445
                                		$expensereportline->fetch($idofelement);
446 446
                                		$idofelement = $expensereportline->fk_expensereport;
447 447
                                	}
@@ -457,63 +457,63 @@  discard block
 block discarded – undo
457 457
                                         $qualifiedfortotal = false; // Replacement invoice
458 458
                                 }
459 459
 
460
-					$showpricebeforepagebreak=1;
460
+					$showpricebeforepagebreak = 1;
461 461
 
462 462
 					$pdf->startTransaction();
463 463
 					// Label
464 464
 					$pdf->SetXY($this->posxref, $curY);
465 465
 					$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
466
-					$pageposafter=$pdf->getPage();
466
+					$pageposafter = $pdf->getPage();
467 467
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
468 468
 					{
469 469
 						$pdf->rollbackTransaction(true);
470
-						$pageposafter=$pageposbefore;
470
+						$pageposafter = $pageposbefore;
471 471
 						//print $pageposafter.'-'.$pageposbefore;exit;
472
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
473 473
 						// Label
474 474
 						$pdf->SetXY($this->posxref, $curY);
475
-						$posybefore=$pdf->GetY();
475
+						$posybefore = $pdf->GetY();
476 476
 						$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
477
-						$pageposafter=$pdf->getPage();
478
-						$posyafter=$pdf->GetY();
479
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
477
+						$pageposafter = $pdf->getPage();
478
+						$posyafter = $pdf->GetY();
479
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
480 480
 						{
481
-							if ($i == ($num-1))	// No more lines, and no space left to show total, so we create a new page
481
+							if ($i == ($num - 1))	// No more lines, and no space left to show total, so we create a new page
482 482
 							{
483
-								$pdf->AddPage('','',true);
484
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
483
+								$pdf->AddPage('', '', true);
484
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
485 485
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
486
-								$pdf->setPage($pageposafter+1);
486
+								$pdf->setPage($pageposafter + 1);
487 487
 							}
488 488
 						}
489 489
 						else
490 490
 						{
491 491
 							// We found a page break
492
-							$showpricebeforepagebreak=0;
493
-							$forcedesconsamepage=1;
492
+							$showpricebeforepagebreak = 0;
493
+							$forcedesconsamepage = 1;
494 494
 							if ($forcedesconsamepage)
495 495
 							{
496 496
 								$pdf->rollbackTransaction(true);
497
-								$pageposafter=$pageposbefore;
498
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
497
+								$pageposafter = $pageposbefore;
498
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
499 499
 
500
-								$pdf->AddPage('','',true);
501
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
500
+								$pdf->AddPage('', '', true);
501
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
502 502
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
503
-								$pdf->setPage($pageposafter+1);
504
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
505
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
506
-								$pdf->SetTextColor(0,0,0);
503
+								$pdf->setPage($pageposafter + 1);
504
+								$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
505
+								$pdf->MultiCell(0, 3, ''); // Set interline to 3
506
+								$pdf->SetTextColor(0, 0, 0);
507 507
 
508
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
508
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
509 509
 								$curY = $tab_top_newpage + $heightoftitleline + 1;
510 510
 
511 511
 								// Label
512 512
 								$pdf->SetXY($this->posxref, $curY);
513
-								$posybefore=$pdf->GetY();
513
+								$posybefore = $pdf->GetY();
514 514
 								$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
515
-								$pageposafter=$pdf->getPage();
516
-								$posyafter=$pdf->GetY();
515
+								$pageposafter = $pdf->getPage();
516
+								$posyafter = $pdf->GetY();
517 517
 							}
518 518
 						}
519 519
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
@@ -522,13 +522,13 @@  discard block
 block discarded – undo
522 522
 					{
523 523
 						$pdf->commitTransaction();
524 524
 					}
525
-					$posYAfterDescription=$pdf->GetY();
525
+					$posYAfterDescription = $pdf->GetY();
526 526
 
527 527
 					$nexY = $pdf->GetY();
528
-					$pageposafter=$pdf->getPage();
528
+					$pageposafter = $pdf->getPage();
529 529
 					$pdf->setPage($pageposbefore);
530 530
 					$pdf->setTopMargin($this->marge_haute);
531
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
531
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
532 532
 
533 533
 					// We suppose that a too long description is moved completely on next page
534 534
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
537 537
 					}
538 538
 
539
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
539
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
540 540
 
541 541
 					// Date
542 542
 					if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
 					$pdf->SetXY($this->posxsociety, $curY);
558 558
 					if ($classname == 'ExpenseReport')
559 559
 					{
560
-						$fuser=new User($this->db);
560
+						$fuser = new User($this->db);
561 561
 						$fuser->fetch($element->fk_user_author);
562 562
 						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
563 563
 					}
564 564
 					else
565 565
 					{
566
-						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L');
566
+						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L');
567 567
 					}
568 568
 
569 569
                                 // Amount without tax
@@ -612,23 +612,23 @@  discard block
 block discarded – undo
612 612
                                 $pdf->SetXY($this->posxamountttc, $curY);
613 613
                                 $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : '&nbsp;'), 1, 'R');
614 614
                                 $pdf->SetXY($this->posxstatut, $curY);
615
-                                $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb") . " " . $num, 1, 'L');
615
+                                $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L');
616 616
                             }
617 617
                             $nexY = $pdf->GetY() + 5;
618 618
                             $curY = $nexY;
619 619
                         }
620 620
                     }
621 621
 
622
-					$nexY+=2;    // Passe espace entre les lignes
622
+					$nexY += 2; // Passe espace entre les lignes
623 623
 
624 624
 					// Detect if some page were added automatically and output _tableau for past pages
625 625
 					while ($pagenb < $pageposafter)
626 626
 					{
627 627
 						$pdf->setPage($pagenb);
628
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
628
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
629 629
 						$pagenb++;
630 630
 						$pdf->setPage($pagenb);
631
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
631
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
632 632
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
633 633
 					}
634 634
 				}
@@ -643,26 +643,26 @@  discard block
 block discarded – undo
643 643
 
644 644
 				// Add pdfgeneration hook
645 645
 				$hookmanager->initHooks(array('pdfgeneration'));
646
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
646
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
647 647
 				global $action;
648
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
648
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
649 649
 
650
-				if (! empty($conf->global->MAIN_UMASK))
650
+				if (!empty($conf->global->MAIN_UMASK))
651 651
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
652 652
 
653 653
 				$this->result = array('fullpath'=>$file);
654 654
 
655
-				return 1;   // Pas d'erreur
655
+				return 1; // Pas d'erreur
656 656
 			}
657 657
 			else
658 658
 			{
659
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
659
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
660 660
 				return 0;
661 661
 			}
662 662
 		}
663 663
 		else
664 664
 		{
665
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
665
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
666 666
 			return 0;
667 667
 		}
668 668
 	}
@@ -680,41 +680,41 @@  discard block
 block discarded – undo
680 680
 	 *   @param		int			$hidebottom		Hide bottom bar of array
681 681
 	 *   @return	void
682 682
 	 */
683
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
683
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
684 684
 	{
685
-		global $conf,$mysoc;
685
+		global $conf, $mysoc;
686 686
 
687 687
 		$heightoftitleline = 10;
688 688
 
689 689
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
690 690
 
691
-		$pdf->SetDrawColor(128,128,128);
691
+		$pdf->SetDrawColor(128, 128, 128);
692 692
 
693 693
 		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
694
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
694
+		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
695 695
 
696 696
 		// line prend une position y en 3eme param
697
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
697
+		$pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
698 698
 
699
-		$pdf->SetTextColor(0,0,0);
700
-		$pdf->SetFont('','', $default_font_size);
699
+		$pdf->SetTextColor(0, 0, 0);
700
+		$pdf->SetFont('', '', $default_font_size);
701 701
 
702
-		$pdf->SetXY($this->posxref, $tab_top+1);
703
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
702
+		$pdf->SetXY($this->posxref, $tab_top + 1);
703
+		$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
704 704
 
705
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
706
-		$pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
705
+		$pdf->SetXY($this->posxlabel, $tab_top + 1);
706
+		$pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
707 707
 
708
-		$pdf->SetXY($this->posxworkload, $tab_top+1);
709
-		$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
708
+		$pdf->SetXY($this->posxworkload, $tab_top + 1);
709
+		$pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
710 710
 
711
-		$pdf->SetXY($this->posxprogress, $tab_top+1);
712
-		$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
711
+		$pdf->SetXY($this->posxprogress, $tab_top + 1);
712
+		$pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
713 713
 
714
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
715
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
714
+		$pdf->SetXY($this->posxdatestart, $tab_top + 1);
715
+		$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C');
716 716
 
717
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
717
+		$pdf->SetXY($this->posxdateend, $tab_top + 1);
718 718
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
719 719
 	}
720 720
 
@@ -729,62 +729,62 @@  discard block
 block discarded – undo
729 729
 	 */
730 730
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
731 731
 	{
732
-		global $langs,$conf,$mysoc;
732
+		global $langs, $conf, $mysoc;
733 733
 
734 734
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
735 735
 
736
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
736
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
737 737
 
738
-		$pdf->SetTextColor(0,0,60);
739
-		$pdf->SetFont('','B', $default_font_size + 3);
738
+		$pdf->SetTextColor(0, 0, 60);
739
+		$pdf->SetFont('', 'B', $default_font_size + 3);
740 740
 
741
-        $posx=$this->page_largeur-$this->marge_droite-100;
742
-		$posy=$this->marge_haute;
741
+        $posx = $this->page_largeur - $this->marge_droite - 100;
742
+		$posy = $this->marge_haute;
743 743
 
744
-		$pdf->SetXY($this->marge_gauche,$posy);
744
+		$pdf->SetXY($this->marge_gauche, $posy);
745 745
 
746 746
 		// Logo
747
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
747
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
748 748
 		if ($mysoc->logo)
749 749
 		{
750 750
 			if (is_readable($logo))
751 751
 			{
752
-			    $height=pdf_getHeightForLogo($logo);
753
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
752
+			    $height = pdf_getHeightForLogo($logo);
753
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
754 754
 			}
755 755
 			else
756 756
 			{
757
-				$pdf->SetTextColor(200,0,0);
758
-				$pdf->SetFont('','B', $default_font_size - 2);
759
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
757
+				$pdf->SetTextColor(200, 0, 0);
758
+				$pdf->SetFont('', 'B', $default_font_size - 2);
759
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
760 760
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
761 761
 			}
762 762
 		}
763 763
 		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
764 764
 
765
-		$pdf->SetFont('','B', $default_font_size + 3);
766
-		$pdf->SetXY($posx,$posy);
767
-		$pdf->SetTextColor(0,0,60);
765
+		$pdf->SetFont('', 'B', $default_font_size + 3);
766
+		$pdf->SetXY($posx, $posy);
767
+		$pdf->SetTextColor(0, 0, 60);
768 768
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
769
-		$pdf->SetFont('','', $default_font_size + 2);
769
+		$pdf->SetFont('', '', $default_font_size + 2);
770 770
 
771
-		$posy+=6;
772
-		$pdf->SetXY($posx,$posy);
773
-		$pdf->SetTextColor(0,0,60);
774
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
771
+		$posy += 6;
772
+		$pdf->SetXY($posx, $posy);
773
+		$pdf->SetTextColor(0, 0, 60);
774
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
775 775
 
776
-		$posy+=6;
777
-		$pdf->SetXY($posx,$posy);
778
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
776
+		$posy += 6;
777
+		$pdf->SetXY($posx, $posy);
778
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
779 779
 
780 780
 		if (is_object($object->thirdparty))
781 781
 		{
782
-			$posy+=6;
783
-			$pdf->SetXY($posx,$posy);
784
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
782
+			$posy += 6;
783
+			$pdf->SetXY($posx, $posy);
784
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
785 785
 		}
786 786
 
787
-		$pdf->SetTextColor(0,0,60);
787
+		$pdf->SetTextColor(0, 0, 60);
788 788
 	}
789 789
 
790 790
 	/**
@@ -796,10 +796,10 @@  discard block
 block discarded – undo
796 796
 	 *      @param	int			$hidefreetext		1=Hide free text
797 797
 	 *      @return	integer
798 798
 	 */
799
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
799
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
800 800
 	{
801 801
 		global $conf;
802
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
803
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
802
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
803
+		return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
804 804
 	}
805 805
 }
Please login to merge, or discard this patch.
Braces   +118 added lines, -59 removed lines patch added patch discarded remove patch
@@ -34,17 +34,39 @@  discard block
 block discarded – undo
34 34
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 35
 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
36 36
 
37
-if (! empty($conf->propal->enabled))        require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
38
-if (! empty($conf->facture->enabled))       require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
39
-if (! empty($conf->facture->enabled))       require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
40
-if (! empty($conf->commande->enabled))      require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
41
-if (! empty($conf->fournisseur->enabled))   require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
42
-if (! empty($conf->fournisseur->enabled))   require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
43
-if (! empty($conf->contrat->enabled))       require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
44
-if (! empty($conf->ficheinter->enabled))    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
45
-if (! empty($conf->deplacement->enabled))   require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
46
-if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
47
-if (! empty($conf->agenda->enabled))        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
37
+if (! empty($conf->propal->enabled)) {
38
+    require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
39
+}
40
+if (! empty($conf->facture->enabled)) {
41
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
+}
43
+if (! empty($conf->facture->enabled)) {
44
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
45
+}
46
+if (! empty($conf->commande->enabled)) {
47
+    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
48
+}
49
+if (! empty($conf->fournisseur->enabled)) {
50
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
51
+}
52
+if (! empty($conf->fournisseur->enabled)) {
53
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
54
+}
55
+if (! empty($conf->contrat->enabled)) {
56
+    require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
57
+}
58
+if (! empty($conf->ficheinter->enabled)) {
59
+    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
60
+}
61
+if (! empty($conf->deplacement->enabled)) {
62
+    require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
63
+}
64
+if (! empty($conf->expensereport->enabled)) {
65
+    require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
66
+}
67
+if (! empty($conf->agenda->enabled)) {
68
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
69
+}
48 70
 
49 71
 
50 72
 
@@ -93,7 +115,10 @@  discard block
 block discarded – undo
93 115
 
94 116
 		// Recupere emmetteur
95 117
 		$this->emetteur=$mysoc;
96
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
118
+		if (! $this->emetteur->country_code) {
119
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
120
+		}
121
+		// By default if not defined
97 122
 
98 123
 		// Defini position des colonnes
99 124
 		$this->posxref=$this->marge_gauche+1;
@@ -102,9 +127,11 @@  discard block
 block discarded – undo
102 127
 		$this->posxamountht=$this->marge_gauche+110;
103 128
 		$this->posxamountttc=$this->marge_gauche+135;
104 129
 		$this->posxstatut=$this->marge_gauche+165;
105
-		if ($this->page_largeur < 210) // To work with US executive format
130
+		if ($this->page_largeur < 210) {
131
+		    // To work with US executive format
106 132
 		{
107 133
 			$this->posxref-=20;
134
+		}
108 135
 			$this->posxdate-=20;
109 136
 			$this->posxsociete-=20;
110 137
 			$this->posxamountht-=20;
@@ -129,9 +156,13 @@  discard block
 block discarded – undo
129 156
 
130 157
         $formproject=new FormProjets($this->db);
131 158
 
132
-		if (! is_object($outputlangs)) $outputlangs=$langs;
159
+		if (! is_object($outputlangs)) {
160
+		    $outputlangs=$langs;
161
+		}
133 162
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
134
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
163
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
164
+		    $outputlangs->charset_output='ISO-8859-1';
165
+		}
135 166
 
136 167
 		// Load traductions files requiredby by page
137 168
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -142,7 +173,9 @@  discard block
 block discarded – undo
142 173
 
143 174
 			$objectref = dol_sanitizeFileName($object->ref);
144 175
 			$dir = $conf->projet->dir_output;
145
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
176
+			if (! preg_match('/specimen/i',$objectref)) {
177
+			    $dir.= "/" . $objectref;
178
+			}
146 179
 			$file = $dir . "/" . $objectref . ".pdf";
147 180
 
148 181
 			if (! file_exists($dir))
@@ -175,7 +208,9 @@  discard block
 block discarded – undo
175 208
 				$heightforinfotot = 40;	// Height reserved to output the info and total part
176 209
 		        $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
177 210
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
178
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
211
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
212
+	                $heightforfooter+= 6;
213
+	            }
179 214
 
180 215
                 if (class_exists('TCPDF'))
181 216
                 {
@@ -212,13 +247,17 @@  discard block
 block discarded – undo
212 247
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
213 248
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
214 249
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
215
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
250
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
251
+				    $pdf->SetCompression(false);
252
+				}
216 253
 
217 254
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
218 255
 
219 256
 				// New page
220 257
 				$pdf->AddPage();
221
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
258
+				if (! empty($tplidx)) {
259
+				    $pdf->useTemplate($tplidx);
260
+				}
222 261
 				$pagenb++;
223 262
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
224 263
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -251,8 +290,7 @@  discard block
 block discarded – undo
251 290
 
252 291
 					$tab_height = $tab_height - $height_note;
253 292
 					$tab_top = $nexY+6;
254
-				}
255
-				else
293
+				} else
256 294
 				{
257 295
 					$height_note=0;
258 296
 				}
@@ -372,7 +410,9 @@  discard block
 block discarded – undo
372 410
                 	$langstoload=$value['lang'];
373 411
                 	$langs->load($langstoload);
374 412
 
375
-                    if (! $qualified) continue;
413
+                    if (! $qualified) {
414
+                        continue;
415
+                    }
376 416
 
377 417
                     //var_dump("$key, $tablename, $datefieldname, $dates, $datee");
378 418
                     $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
@@ -403,7 +443,9 @@  discard block
 block discarded – undo
403 443
                         $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
404 444
                         $pdf->SetXY($this->posxsociety, $curY);
405 445
                         $titlethirdparty=$outputlangs->transnoentities("ThirdParty");
406
-                        if ($classname == 'ExpenseReport') $titlethirdparty=$langs->trans("User");
446
+                        if ($classname == 'ExpenseReport') {
447
+                            $titlethirdparty=$langs->trans("User");
448
+                        }
407 449
                         $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L');
408 450
                         if (empty($value['disableamount'])) {
409 451
                             $pdf->SetXY($this->posxamountht, $curY);
@@ -453,8 +495,10 @@  discard block
 block discarded – undo
453 495
 
454 496
                                 $qualifiedfortotal = true;
455 497
                                 if ($key == 'invoice') {
456
-                                    if ($element->close_code == 'replaced')
457
-                                        $qualifiedfortotal = false; // Replacement invoice
498
+                                    if ($element->close_code == 'replaced') {
499
+                                                                            $qualifiedfortotal = false;
500
+                                    }
501
+                                    // Replacement invoice
458 502
                                 }
459 503
 
460 504
 					$showpricebeforepagebreak=1;
@@ -464,9 +508,11 @@  discard block
 block discarded – undo
464 508
 					$pdf->SetXY($this->posxref, $curY);
465 509
 					$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
466 510
 					$pageposafter=$pdf->getPage();
467
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
511
+					if ($pageposafter > $pageposbefore) {
512
+					    // There is a pagebreak
468 513
 					{
469 514
 						$pdf->rollbackTransaction(true);
515
+					}
470 516
 						$pageposafter=$pageposbefore;
471 517
 						//print $pageposafter.'-'.$pageposbefore;exit;
472 518
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -476,17 +522,22 @@  discard block
 block discarded – undo
476 522
 						$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
477 523
 						$pageposafter=$pdf->getPage();
478 524
 						$posyafter=$pdf->GetY();
479
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
525
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
526
+						    // There is no space left for total+free text
480 527
 						{
481 528
 							if ($i == ($num-1))	// No more lines, and no space left to show total, so we create a new page
482 529
 							{
483 530
 								$pdf->AddPage('','',true);
484
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
+						}
532
+								if (! empty($tplidx)) {
533
+								    $pdf->useTemplate($tplidx);
534
+								}
535
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
536
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
537
+								}
486 538
 								$pdf->setPage($pageposafter+1);
487 539
 							}
488
-						}
489
-						else
540
+						} else
490 541
 						{
491 542
 							// We found a page break
492 543
 							$showpricebeforepagebreak=0;
@@ -498,8 +549,12 @@  discard block
 block discarded – undo
498 549
 								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
499 550
 
500 551
 								$pdf->AddPage('','',true);
501
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
502
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
552
+								if (! empty($tplidx)) {
553
+								    $pdf->useTemplate($tplidx);
554
+								}
555
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
556
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
557
+								}
503 558
 								$pdf->setPage($pageposafter+1);
504 559
 								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
505 560
 								$pdf->MultiCell(0, 3, '');		// Set interline to 3
@@ -517,8 +572,7 @@  discard block
 block discarded – undo
517 572
 							}
518 573
 						}
519 574
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
520
-					}
521
-					else	// No pagebreak
575
+					} else	// No pagebreak
522 576
 					{
523 577
 						$pdf->commitTransaction();
524 578
 					}
@@ -539,16 +593,20 @@  discard block
 block discarded – undo
539 593
 					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
540 594
 
541 595
 					// Date
542
-					if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
543
-						$date = $element->date_commande;
544
-					else {
596
+					if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') {
597
+											$date = $element->date_commande;
598
+					} else {
545 599
 						$date = $element->date;
546
-						if (empty($date))
547
-							$date = $element->datep;
548
-						if (empty($date))
549
-							$date = $element->date_contrat;
550
-						if (empty($date))
551
-							$date = $element->datev; // Fiche inter
600
+						if (empty($date)) {
601
+													$date = $element->datep;
602
+						}
603
+						if (empty($date)) {
604
+													$date = $element->date_contrat;
605
+						}
606
+						if (empty($date)) {
607
+													$date = $element->datev;
608
+						}
609
+						// Fiche inter
552 610
 					}
553 611
 
554 612
 					$pdf->SetXY($this->posxdate, $curY);
@@ -560,8 +618,7 @@  discard block
 block discarded – undo
560 618
 						$fuser=new User($this->db);
561 619
 						$fuser->fetch($element->fk_user_author);
562 620
 						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
563
-					}
564
-					else
621
+					} else
565 622
 					{
566 623
 						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L');
567 624
 					}
@@ -578,8 +635,7 @@  discard block
 block discarded – undo
578 635
                                 	{
579 636
                                 		$textforamount = dol_trunc($element->label, 26);
580 637
                                 		$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L');
581
-                                	}
582
-                                	else
638
+                                	} else
583 639
                                 	{
584 640
 	                                    $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
585 641
                                 	}
@@ -629,13 +685,17 @@  discard block
 block discarded – undo
629 685
 						$pagenb++;
630 686
 						$pdf->setPage($pagenb);
631 687
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
632
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
688
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
689
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
690
+						}
633 691
 					}
634 692
 				}
635 693
 
636 694
 				// Pied de page
637 695
 				$this->_pagefoot($pdf, $object, $outputlangs);
638
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
696
+				if (method_exists($pdf, 'AliasNbPages')) {
697
+				    $pdf->AliasNbPages();
698
+				}
639 699
 
640 700
 				$pdf->Close();
641 701
 
@@ -647,20 +707,19 @@  discard block
 block discarded – undo
647 707
 				global $action;
648 708
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
649 709
 
650
-				if (! empty($conf->global->MAIN_UMASK))
651
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
710
+				if (! empty($conf->global->MAIN_UMASK)) {
711
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
712
+				}
652 713
 
653 714
 				$this->result = array('fullpath'=>$file);
654 715
 
655 716
 				return 1;   // Pas d'erreur
656
-			}
657
-			else
717
+			} else
658 718
 			{
659 719
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
660 720
 				return 0;
661 721
 			}
662
-		}
663
-		else
722
+		} else
664 723
 		{
665 724
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
666 725
 			return 0;
@@ -751,16 +810,16 @@  discard block
 block discarded – undo
751 810
 			{
752 811
 			    $height=pdf_getHeightForLogo($logo);
753 812
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
754
-			}
755
-			else
813
+			} else
756 814
 			{
757 815
 				$pdf->SetTextColor(200,0,0);
758 816
 				$pdf->SetFont('','B', $default_font_size - 2);
759 817
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
760 818
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
761 819
 			}
820
+		} else {
821
+		    $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
762 822
 		}
763
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
764 823
 
765 824
 		$pdf->SetFont('','B', $default_font_size + 3);
766 825
 		$pdf->SetXY($posx,$posy);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/doc/pdf_timespent.modules.php 3 patches
Indentation   +503 added lines, -503 removed lines patch added patch discarded remove patch
@@ -37,125 +37,125 @@  discard block
 block discarded – undo
37 37
 
38 38
 class pdf_timespent extends ModelePDFProjects
39 39
 {
40
-	/**
41
-	 * Issuer
42
-	 * @var Societe
43
-	 */
44
-	public $emetteur;
45
-
46
-	/**
47
-	 *	Constructor
48
-	 *
49
-	 *  @param		DoliDB		$db      Database handler
50
-	 */
51
-	function __construct($db)
52
-	{
53
-		global $conf,$langs,$mysoc;
54
-
55
-		// Translations
56
-		$langs->loadLangs(array("main", "projects", "companies"));
57
-
58
-		$this->db = $db;
59
-		$this->name = "timespent";
60
-		$this->description = $langs->trans("DocumentModelTimeSpent");
61
-
62
-		// Dimension page pour format A4
63
-		$this->type = 'pdf';
64
-		$formatarray=pdf_getFormat();
65
-		$this->page_largeur = $formatarray['width'];
66
-		$this->page_hauteur = $formatarray['height'];
67
-		$this->format = array($this->page_largeur,$this->page_hauteur);
68
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
69
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
70
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
71
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
72
-
73
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
74
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
75
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
76
-
77
-		// Recupere emmetteur
78
-		$this->emetteur=$mysoc;
79
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
80
-
81
-		// Defini position des colonnes
82
-		$this->posxref=$this->marge_gauche+1;
83
-		$this->posxlabel=$this->marge_gauche+25;
84
-		$this->posxtimespent=$this->marge_gauche+120;
85
-		//$this->posxprogress=$this->marge_gauche+140;
86
-		$this->posxdatestart=$this->marge_gauche+152;
87
-		$this->posxdateend=$this->marge_gauche+170;
88
-		if ($this->page_largeur < 210) // To work with US executive format
89
-		{
90
-			$this->posxref-=20;
91
-			$this->posxlabel-=20;
92
-			$this->posxtimespent-=20;
93
-			//$this->posxprogress-=20;
94
-			$this->posxdatestart-=20;
95
-			$this->posxdateend-=20;
96
-		}
97
-	}
40
+    /**
41
+     * Issuer
42
+     * @var Societe
43
+     */
44
+    public $emetteur;
45
+
46
+    /**
47
+     *	Constructor
48
+     *
49
+     *  @param		DoliDB		$db      Database handler
50
+     */
51
+    function __construct($db)
52
+    {
53
+        global $conf,$langs,$mysoc;
54
+
55
+        // Translations
56
+        $langs->loadLangs(array("main", "projects", "companies"));
57
+
58
+        $this->db = $db;
59
+        $this->name = "timespent";
60
+        $this->description = $langs->trans("DocumentModelTimeSpent");
61
+
62
+        // Dimension page pour format A4
63
+        $this->type = 'pdf';
64
+        $formatarray=pdf_getFormat();
65
+        $this->page_largeur = $formatarray['width'];
66
+        $this->page_hauteur = $formatarray['height'];
67
+        $this->format = array($this->page_largeur,$this->page_hauteur);
68
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
69
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
70
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
71
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
72
+
73
+        $this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
74
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
75
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
76
+
77
+        // Recupere emmetteur
78
+        $this->emetteur=$mysoc;
79
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
80
+
81
+        // Defini position des colonnes
82
+        $this->posxref=$this->marge_gauche+1;
83
+        $this->posxlabel=$this->marge_gauche+25;
84
+        $this->posxtimespent=$this->marge_gauche+120;
85
+        //$this->posxprogress=$this->marge_gauche+140;
86
+        $this->posxdatestart=$this->marge_gauche+152;
87
+        $this->posxdateend=$this->marge_gauche+170;
88
+        if ($this->page_largeur < 210) // To work with US executive format
89
+        {
90
+            $this->posxref-=20;
91
+            $this->posxlabel-=20;
92
+            $this->posxtimespent-=20;
93
+            //$this->posxprogress-=20;
94
+            $this->posxdatestart-=20;
95
+            $this->posxdateend-=20;
96
+        }
97
+    }
98 98
 
99 99
 
100 100
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
101
-	/**
102
-	 *	Fonction generant le projet sur le disque
103
-	 *
104
-	 *	@param	Project		$object   		Object project a generer
105
-	 *	@param	Translate	$outputlangs	Lang output object
106
-	 *	@return	int         				1 if OK, <=0 if KO
107
-	 */
108
-	function write_file($object,$outputlangs)
109
-	{
101
+    /**
102
+     *	Fonction generant le projet sur le disque
103
+     *
104
+     *	@param	Project		$object   		Object project a generer
105
+     *	@param	Translate	$outputlangs	Lang output object
106
+     *	@return	int         				1 if OK, <=0 if KO
107
+     */
108
+    function write_file($object,$outputlangs)
109
+    {
110 110
         // phpcs:enable
111
-		global $conf, $hookmanager, $langs, $user;
112
-
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
114
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
116
-
117
-		// Load traductions files requiredby by page
118
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
119
-
120
-		if ($conf->projet->dir_output)
121
-		{
122
-			//$nblignes = count($object->lines);  // This is set later with array of tasks
123
-
124
-			$objectref = dol_sanitizeFileName($object->ref);
125
-			$dir = $conf->projet->dir_output;
126
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
127
-			$file = $dir . "/" . $objectref . ".pdf";
128
-
129
-			if (! file_exists($dir))
130
-			{
131
-				if (dol_mkdir($dir) < 0)
132
-				{
133
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
134
-					return 0;
135
-				}
136
-			}
137
-
138
-			if (file_exists($dir))
139
-			{
140
-				// Add pdfgeneration hook
141
-				if (! is_object($hookmanager))
142
-				{
143
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
144
-					$hookmanager=new HookManager($this->db);
145
-				}
146
-				$hookmanager->initHooks(array('pdfgeneration'));
147
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
148
-				global $action;
149
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
150
-
151
-				// Create pdf instance
152
-				$pdf=pdf_getInstance($this->format);
153
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
154
-				$pdf->SetAutoPageBreak(1,0);
155
-
156
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
157
-		        $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
158
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
111
+        global $conf, $hookmanager, $langs, $user;
112
+
113
+        if (! is_object($outputlangs)) $outputlangs=$langs;
114
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
116
+
117
+        // Load traductions files requiredby by page
118
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
119
+
120
+        if ($conf->projet->dir_output)
121
+        {
122
+            //$nblignes = count($object->lines);  // This is set later with array of tasks
123
+
124
+            $objectref = dol_sanitizeFileName($object->ref);
125
+            $dir = $conf->projet->dir_output;
126
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
127
+            $file = $dir . "/" . $objectref . ".pdf";
128
+
129
+            if (! file_exists($dir))
130
+            {
131
+                if (dol_mkdir($dir) < 0)
132
+                {
133
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
134
+                    return 0;
135
+                }
136
+            }
137
+
138
+            if (file_exists($dir))
139
+            {
140
+                // Add pdfgeneration hook
141
+                if (! is_object($hookmanager))
142
+                {
143
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
144
+                    $hookmanager=new HookManager($this->db);
145
+                }
146
+                $hookmanager->initHooks(array('pdfgeneration'));
147
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
148
+                global $action;
149
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
150
+
151
+                // Create pdf instance
152
+                $pdf=pdf_getInstance($this->format);
153
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
154
+                $pdf->SetAutoPageBreak(1,0);
155
+
156
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
157
+                $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
158
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
159 159
 
160 160
                 if (class_exists('TCPDF'))
161 161
                 {
@@ -170,403 +170,403 @@  discard block
 block discarded – undo
170 170
                     $tplidx = $pdf->importPage(1);
171 171
                 }
172 172
 
173
-				// Complete object by loading several other informations
174
-				$task = new Task($this->db);
175
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
173
+                // Complete object by loading several other informations
174
+                $task = new Task($this->db);
175
+                $tasksarray = $task->getTasksArray(0,0,$object->id);
176 176
 
177 177
                 if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
178 178
                 {
179 179
                     $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
180 180
                 }
181 181
 
182
-				$object->lines=$tasksarray;
183
-				$nblignes=count($object->lines);
184
-
185
-				$pdf->Open();
186
-				$pagenb=0;
187
-				$pdf->SetDrawColor(128,128,128);
188
-
189
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
190
-				$pdf->SetSubject($outputlangs->transnoentities("Project"));
191
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
192
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
195
-
196
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
197
-
198
-				// New page
199
-				$pdf->AddPage();
200
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
201
-				$pagenb++;
202
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
203
-				$pdf->SetFont('','', $default_font_size - 1);
204
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
205
-				$pdf->SetTextColor(0,0,0);
206
-
207
-				$tab_top = 50;
208
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
209
-				$tab_height = 170;
210
-				$tab_height_newpage = 190;
211
-
212
-				// Show public note
213
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
214
-				if ($notetoshow)
215
-				{
216
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
217
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
218
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
219
-
220
-					$tab_top -= 2;
221
-
222
-					$pdf->SetFont('','', $default_font_size - 1);
223
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
224
-					$nexY = $pdf->GetY();
225
-					$height_note=$nexY-$tab_top;
226
-
227
-					// Rect prend une longueur en 3eme param
228
-					$pdf->SetDrawColor(192,192,192);
229
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
230
-
231
-					$tab_height = $tab_height - $height_note;
232
-					$tab_top = $nexY+6;
233
-				}
234
-				else
235
-				{
236
-					$height_note=0;
237
-				}
238
-
239
-				$heightoftitleline = 10;
240
-				$iniY = $tab_top + $heightoftitleline + 1;
241
-				$curY = $tab_top + $heightoftitleline + 1;
242
-				$nexY = $tab_top + $heightoftitleline + 1;
243
-
244
-				// Loop on each lines
245
-				for ($i = 0 ; $i < $nblignes ; $i++)
246
-				{
247
-					$curY = $nexY;
248
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
249
-					$pdf->SetTextColor(0,0,0);
250
-
251
-					$pdf->setTopMargin($tab_top_newpage);
252
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
253
-					$pageposbefore=$pdf->getPage();
254
-
255
-					// Description of line
256
-					$ref=$object->lines[$i]->ref;
257
-					$libelleline=$object->lines[$i]->label;
258
-					//$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
259
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
260
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
261
-					$planned_timespent=convertSecondToTime((int) $object->lines[$i]->planned_timespent,'allhourmin');
262
-
263
-					$showpricebeforepagebreak=1;
264
-
265
-					$pdf->startTransaction();
266
-					// Label
267
-					$pdf->SetXY($this->posxlabel, $curY);
268
-					$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
-					$pageposafter=$pdf->getPage();
270
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
271
-					{
272
-						$pdf->rollbackTransaction(true);
273
-						$pageposafter=$pageposbefore;
274
-						//print $pageposafter.'-'.$pageposbefore;exit;
275
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
276
-						// Label
277
-						$pdf->SetXY($this->posxlabel, $curY);
278
-						$posybefore=$pdf->GetY();
279
-						$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
-						$pageposafter=$pdf->getPage();
281
-						$posyafter=$pdf->GetY();
282
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
283
-						{
284
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
285
-							{
286
-								$pdf->AddPage('','',true);
287
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
289
-								$pdf->setPage($pageposafter+1);
290
-							}
291
-						}
292
-						else
293
-						{
294
-							// We found a page break
295
-							$showpricebeforepagebreak=0;
296
-							$forcedesconsamepage=1;
297
-							if ($forcedesconsamepage)
298
-							{
299
-								$pdf->rollbackTransaction(true);
300
-								$pageposafter=$pageposbefore;
301
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
302
-
303
-								$pdf->AddPage('','',true);
304
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
305
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
-								$pdf->setPage($pageposafter+1);
307
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
309
-								$pdf->SetTextColor(0,0,0);
310
-
311
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
312
-								$curY = $tab_top_newpage + $heightoftitleline + 1;
313
-
314
-								// Label
315
-								$pdf->SetXY($this->posxlabel, $curY);
316
-								$posybefore=$pdf->GetY();
317
-								$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
-								$pageposafter=$pdf->getPage();
319
-								$posyafter=$pdf->GetY();
320
-							}
321
-						}
322
-						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
323
-					}
324
-					else	// No pagebreak
325
-					{
326
-						$pdf->commitTransaction();
327
-					}
328
-					$posYAfterDescription=$pdf->GetY();
329
-
330
-					$nexY = $pdf->GetY();
331
-					$pageposafter=$pdf->getPage();
332
-					$pdf->setPage($pageposbefore);
333
-					$pdf->setTopMargin($this->marge_haute);
334
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
335
-
336
-					// We suppose that a too long description is moved completely on next page
337
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
338
-						//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
339
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
340
-					}
341
-
342
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
343
-
344
-					// Ref of task
345
-					$pdf->SetXY($this->posxref, $curY);
346
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
347
-					// timespent
348
-					$pdf->SetXY($this->posxtimespent, $curY);
349
-					$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $planned_timespent?$planned_timespent:'', 0, 'R');
350
-					// Progress
351
-					//$pdf->SetXY($this->posxprogress, $curY);
352
-					//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
353
-					// Date
354
-					$pdf->SetXY($this->posxdatestart, $curY);
355
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
356
-					$pdf->SetXY($this->posxdateend, $curY);
357
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
358
-
359
-					// Add line
360
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361
-					{
362
-						$pdf->setPage($pageposafter);
363
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
364
-						//$pdf->SetDrawColor(190,190,200);
365
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
366
-						$pdf->SetLineStyle(array('dash'=>0));
367
-					}
368
-
369
-					$nexY+=2;    // Passe espace entre les lignes
370
-
371
-					// Detect if some page were added automatically and output _tableau for past pages
372
-					while ($pagenb < $pageposafter)
373
-					{
374
-						$pdf->setPage($pagenb);
375
-						if ($pagenb == 1)
376
-						{
377
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378
-						}
379
-						else
380
-						{
381
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382
-						}
383
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
384
-						$pagenb++;
385
-						$pdf->setPage($pagenb);
386
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388
-					}
389
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390
-					{
391
-						if ($pagenb == 1)
392
-						{
393
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394
-						}
395
-						else
396
-						{
397
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398
-						}
399
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
400
-						// New page
401
-						$pdf->AddPage();
402
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
403
-						$pagenb++;
404
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405
-					}
406
-				}
407
-
408
-				// Show square
409
-				if ($pagenb == 1)
410
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411
-				else
412
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
413
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414
-
415
-				// Pied de page
416
-				$this->_pagefoot($pdf, $object, $outputlangs);
417
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
418
-
419
-				$pdf->Close();
420
-
421
-				$pdf->Output($file, 'F');
422
-
423
-				// Add pdfgeneration hook
424
-				$hookmanager->initHooks(array('pdfgeneration'));
425
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
426
-				global $action;
427
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
428
-
429
-				if (! empty($conf->global->MAIN_UMASK))
430
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
431
-
432
-				$this->result = array('fullpath'=>$file);
433
-
434
-				return 1;   // Pas d'erreur
435
-			}
436
-			else
437
-			{
438
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
439
-				return 0;
440
-			}
441
-		}
442
-		else
443
-		{
444
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
445
-			return 0;
446
-		}
447
-	}
448
-
449
-
450
-	/**
451
-	 *   Show table for lines
452
-	 *
453
-	 *   @param		PDF			$pdf     		Object PDF
454
-	 *   @param		string		$tab_top		Top position of table
455
-	 *   @param		string		$tab_height		Height of table (rectangle)
456
-	 *   @param		int			$nexY			Y
457
-	 *   @param		Translate	$outputlangs	Langs object
458
-	 *   @param		int			$hidetop		Hide top bar of array
459
-	 *   @param		int			$hidebottom		Hide bottom bar of array
460
-	 *   @return	void
461
-	 */
462
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
463
-	{
464
-		global $conf,$mysoc;
465
-
466
-		$heightoftitleline = 10;
182
+                $object->lines=$tasksarray;
183
+                $nblignes=count($object->lines);
184
+
185
+                $pdf->Open();
186
+                $pagenb=0;
187
+                $pdf->SetDrawColor(128,128,128);
188
+
189
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
190
+                $pdf->SetSubject($outputlangs->transnoentities("Project"));
191
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
192
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
195
+
196
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
197
+
198
+                // New page
199
+                $pdf->AddPage();
200
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
201
+                $pagenb++;
202
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
203
+                $pdf->SetFont('','', $default_font_size - 1);
204
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
205
+                $pdf->SetTextColor(0,0,0);
206
+
207
+                $tab_top = 50;
208
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
209
+                $tab_height = 170;
210
+                $tab_height_newpage = 190;
211
+
212
+                // Show public note
213
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
214
+                if ($notetoshow)
215
+                {
216
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
217
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
218
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
219
+
220
+                    $tab_top -= 2;
221
+
222
+                    $pdf->SetFont('','', $default_font_size - 1);
223
+                    $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
224
+                    $nexY = $pdf->GetY();
225
+                    $height_note=$nexY-$tab_top;
226
+
227
+                    // Rect prend une longueur en 3eme param
228
+                    $pdf->SetDrawColor(192,192,192);
229
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
230
+
231
+                    $tab_height = $tab_height - $height_note;
232
+                    $tab_top = $nexY+6;
233
+                }
234
+                else
235
+                {
236
+                    $height_note=0;
237
+                }
238
+
239
+                $heightoftitleline = 10;
240
+                $iniY = $tab_top + $heightoftitleline + 1;
241
+                $curY = $tab_top + $heightoftitleline + 1;
242
+                $nexY = $tab_top + $heightoftitleline + 1;
243
+
244
+                // Loop on each lines
245
+                for ($i = 0 ; $i < $nblignes ; $i++)
246
+                {
247
+                    $curY = $nexY;
248
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
249
+                    $pdf->SetTextColor(0,0,0);
250
+
251
+                    $pdf->setTopMargin($tab_top_newpage);
252
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
253
+                    $pageposbefore=$pdf->getPage();
254
+
255
+                    // Description of line
256
+                    $ref=$object->lines[$i]->ref;
257
+                    $libelleline=$object->lines[$i]->label;
258
+                    //$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
259
+                    $datestart=dol_print_date($object->lines[$i]->date_start,'day');
260
+                    $dateend=dol_print_date($object->lines[$i]->date_end,'day');
261
+                    $planned_timespent=convertSecondToTime((int) $object->lines[$i]->planned_timespent,'allhourmin');
262
+
263
+                    $showpricebeforepagebreak=1;
264
+
265
+                    $pdf->startTransaction();
266
+                    // Label
267
+                    $pdf->SetXY($this->posxlabel, $curY);
268
+                    $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
+                    $pageposafter=$pdf->getPage();
270
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
271
+                    {
272
+                        $pdf->rollbackTransaction(true);
273
+                        $pageposafter=$pageposbefore;
274
+                        //print $pageposafter.'-'.$pageposbefore;exit;
275
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
276
+                        // Label
277
+                        $pdf->SetXY($this->posxlabel, $curY);
278
+                        $posybefore=$pdf->GetY();
279
+                        $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
+                        $pageposafter=$pdf->getPage();
281
+                        $posyafter=$pdf->GetY();
282
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
283
+                        {
284
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
285
+                            {
286
+                                $pdf->AddPage('','',true);
287
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
289
+                                $pdf->setPage($pageposafter+1);
290
+                            }
291
+                        }
292
+                        else
293
+                        {
294
+                            // We found a page break
295
+                            $showpricebeforepagebreak=0;
296
+                            $forcedesconsamepage=1;
297
+                            if ($forcedesconsamepage)
298
+                            {
299
+                                $pdf->rollbackTransaction(true);
300
+                                $pageposafter=$pageposbefore;
301
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
302
+
303
+                                $pdf->AddPage('','',true);
304
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
305
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
+                                $pdf->setPage($pageposafter+1);
307
+                                $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308
+                                $pdf->MultiCell(0, 3, '');		// Set interline to 3
309
+                                $pdf->SetTextColor(0,0,0);
310
+
311
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
312
+                                $curY = $tab_top_newpage + $heightoftitleline + 1;
313
+
314
+                                // Label
315
+                                $pdf->SetXY($this->posxlabel, $curY);
316
+                                $posybefore=$pdf->GetY();
317
+                                $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
+                                $pageposafter=$pdf->getPage();
319
+                                $posyafter=$pdf->GetY();
320
+                            }
321
+                        }
322
+                        //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
323
+                    }
324
+                    else	// No pagebreak
325
+                    {
326
+                        $pdf->commitTransaction();
327
+                    }
328
+                    $posYAfterDescription=$pdf->GetY();
329
+
330
+                    $nexY = $pdf->GetY();
331
+                    $pageposafter=$pdf->getPage();
332
+                    $pdf->setPage($pageposbefore);
333
+                    $pdf->setTopMargin($this->marge_haute);
334
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
335
+
336
+                    // We suppose that a too long description is moved completely on next page
337
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
338
+                        //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
339
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
340
+                    }
341
+
342
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
343
+
344
+                    // Ref of task
345
+                    $pdf->SetXY($this->posxref, $curY);
346
+                    $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
347
+                    // timespent
348
+                    $pdf->SetXY($this->posxtimespent, $curY);
349
+                    $pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $planned_timespent?$planned_timespent:'', 0, 'R');
350
+                    // Progress
351
+                    //$pdf->SetXY($this->posxprogress, $curY);
352
+                    //$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
353
+                    // Date
354
+                    $pdf->SetXY($this->posxdatestart, $curY);
355
+                    $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
356
+                    $pdf->SetXY($this->posxdateend, $curY);
357
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
358
+
359
+                    // Add line
360
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361
+                    {
362
+                        $pdf->setPage($pageposafter);
363
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
364
+                        //$pdf->SetDrawColor(190,190,200);
365
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
366
+                        $pdf->SetLineStyle(array('dash'=>0));
367
+                    }
368
+
369
+                    $nexY+=2;    // Passe espace entre les lignes
370
+
371
+                    // Detect if some page were added automatically and output _tableau for past pages
372
+                    while ($pagenb < $pageposafter)
373
+                    {
374
+                        $pdf->setPage($pagenb);
375
+                        if ($pagenb == 1)
376
+                        {
377
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378
+                        }
379
+                        else
380
+                        {
381
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382
+                        }
383
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
384
+                        $pagenb++;
385
+                        $pdf->setPage($pagenb);
386
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388
+                    }
389
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390
+                    {
391
+                        if ($pagenb == 1)
392
+                        {
393
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394
+                        }
395
+                        else
396
+                        {
397
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398
+                        }
399
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
400
+                        // New page
401
+                        $pdf->AddPage();
402
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
403
+                        $pagenb++;
404
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405
+                    }
406
+                }
407
+
408
+                // Show square
409
+                if ($pagenb == 1)
410
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411
+                else
412
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
413
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414
+
415
+                // Pied de page
416
+                $this->_pagefoot($pdf, $object, $outputlangs);
417
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
418
+
419
+                $pdf->Close();
420
+
421
+                $pdf->Output($file, 'F');
422
+
423
+                // Add pdfgeneration hook
424
+                $hookmanager->initHooks(array('pdfgeneration'));
425
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
426
+                global $action;
427
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
428
+
429
+                if (! empty($conf->global->MAIN_UMASK))
430
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
431
+
432
+                $this->result = array('fullpath'=>$file);
433
+
434
+                return 1;   // Pas d'erreur
435
+            }
436
+            else
437
+            {
438
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
439
+                return 0;
440
+            }
441
+        }
442
+        else
443
+        {
444
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
445
+            return 0;
446
+        }
447
+    }
448
+
449
+
450
+    /**
451
+     *   Show table for lines
452
+     *
453
+     *   @param		PDF			$pdf     		Object PDF
454
+     *   @param		string		$tab_top		Top position of table
455
+     *   @param		string		$tab_height		Height of table (rectangle)
456
+     *   @param		int			$nexY			Y
457
+     *   @param		Translate	$outputlangs	Langs object
458
+     *   @param		int			$hidetop		Hide top bar of array
459
+     *   @param		int			$hidebottom		Hide bottom bar of array
460
+     *   @return	void
461
+     */
462
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
463
+    {
464
+        global $conf,$mysoc;
465
+
466
+        $heightoftitleline = 10;
467 467
 
468 468
         $default_font_size = pdf_getPDFFontSize($outputlangs);
469 469
 
470
-		$pdf->SetDrawColor(128,128,128);
470
+        $pdf->SetDrawColor(128,128,128);
471 471
 
472
-		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
473
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
472
+        // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
473
+        $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
474 474
 
475
-		// line prend une position y en 3eme param
476
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
475
+        // line prend une position y en 3eme param
476
+        $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
477 477
 
478
-		$pdf->SetTextColor(0,0,0);
479
-		$pdf->SetFont('','', $default_font_size);
478
+        $pdf->SetTextColor(0,0,0);
479
+        $pdf->SetFont('','', $default_font_size);
480 480
 
481
-		$pdf->SetXY($this->posxref, $tab_top+1);
482
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
481
+        $pdf->SetXY($this->posxref, $tab_top+1);
482
+        $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
483 483
 
484
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
485
-		$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
484
+        $pdf->SetXY($this->posxlabel, $tab_top+1);
485
+        $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
486 486
 
487
-		$pdf->SetXY($this->posxtimespent, $tab_top+1);
488
-		$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
487
+        $pdf->SetXY($this->posxtimespent, $tab_top+1);
488
+        $pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
489 489
 
490
-		//$pdf->SetXY($this->posxprogress, $tab_top+1);
491
-		//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
490
+        //$pdf->SetXY($this->posxprogress, $tab_top+1);
491
+        //$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
492 492
 
493
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
494
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
493
+        $pdf->SetXY($this->posxdatestart, $tab_top+1);
494
+        $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
495 495
 
496
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
497
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
498
-	}
496
+        $pdf->SetXY($this->posxdateend, $tab_top+1);
497
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
498
+    }
499 499
 
500
-	/**
501
-	 *  Show top header of page.
502
-	 *
503
-	 *  @param	PDF			$pdf     		Object PDF
504
-	 *  @param  Project		$object     	Object to show
505
-	 *  @param  int	    	$showaddress    0=no, 1=yes
506
-	 *  @param  Translate	$outputlangs	Object lang for output
507
-	 *  @return	void
508
-	 */
509
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
510
-	{
511
-		global $langs,$conf,$mysoc;
500
+    /**
501
+     *  Show top header of page.
502
+     *
503
+     *  @param	PDF			$pdf     		Object PDF
504
+     *  @param  Project		$object     	Object to show
505
+     *  @param  int	    	$showaddress    0=no, 1=yes
506
+     *  @param  Translate	$outputlangs	Object lang for output
507
+     *  @return	void
508
+     */
509
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
510
+    {
511
+        global $langs,$conf,$mysoc;
512 512
 
513
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
513
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
514 514
 
515
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
515
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
516 516
 
517
-		$pdf->SetTextColor(0,0,60);
518
-		$pdf->SetFont('','B', $default_font_size + 3);
517
+        $pdf->SetTextColor(0,0,60);
518
+        $pdf->SetFont('','B', $default_font_size + 3);
519 519
 
520 520
         $posx=$this->page_largeur-$this->marge_droite-100;
521
-		$posy=$this->marge_haute;
522
-
523
-		$pdf->SetXY($this->marge_gauche,$posy);
524
-
525
-		// Logo
526
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
527
-		if ($mysoc->logo)
528
-		{
529
-			if (is_readable($logo))
530
-			{
531
-			    $height=pdf_getHeightForLogo($logo);
532
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
533
-			}
534
-			else
535
-			{
536
-				$pdf->SetTextColor(200,0,0);
537
-				$pdf->SetFont('','B', $default_font_size - 2);
538
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
539
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540
-			}
541
-		}
542
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543
-
544
-		$pdf->SetFont('','B', $default_font_size + 3);
545
-		$pdf->SetXY($posx,$posy);
546
-		$pdf->SetTextColor(0,0,60);
547
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
548
-		$pdf->SetFont('','', $default_font_size + 2);
549
-
550
-		$posy+=6;
551
-		$pdf->SetXY($posx,$posy);
552
-		$pdf->SetTextColor(0,0,60);
553
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
554
-
555
-		$posy+=6;
556
-		$pdf->SetXY($posx,$posy);
557
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
558
-
559
-		if (is_object($object->thirdparty))
560
-		{
561
-			$posy+=6;
562
-			$pdf->SetXY($posx,$posy);
563
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
564
-		}
565
-
566
-		$pdf->SetTextColor(0,0,60);
567
-
568
-		// Add list of linked objects
569
-		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
521
+        $posy=$this->marge_haute;
522
+
523
+        $pdf->SetXY($this->marge_gauche,$posy);
524
+
525
+        // Logo
526
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
527
+        if ($mysoc->logo)
528
+        {
529
+            if (is_readable($logo))
530
+            {
531
+                $height=pdf_getHeightForLogo($logo);
532
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
533
+            }
534
+            else
535
+            {
536
+                $pdf->SetTextColor(200,0,0);
537
+                $pdf->SetFont('','B', $default_font_size - 2);
538
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
539
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540
+            }
541
+        }
542
+        else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543
+
544
+        $pdf->SetFont('','B', $default_font_size + 3);
545
+        $pdf->SetXY($posx,$posy);
546
+        $pdf->SetTextColor(0,0,60);
547
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
548
+        $pdf->SetFont('','', $default_font_size + 2);
549
+
550
+        $posy+=6;
551
+        $pdf->SetXY($posx,$posy);
552
+        $pdf->SetTextColor(0,0,60);
553
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
554
+
555
+        $posy+=6;
556
+        $pdf->SetXY($posx,$posy);
557
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
558
+
559
+        if (is_object($object->thirdparty))
560
+        {
561
+            $posy+=6;
562
+            $pdf->SetXY($posx,$posy);
563
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
564
+        }
565
+
566
+        $pdf->SetTextColor(0,0,60);
567
+
568
+        // Add list of linked objects
569
+        /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
570 570
 		$object->fetchObjectLinked();
571 571
 
572 572
 	    foreach($object->linkedObjects as $objecttype => $objects)
@@ -588,21 +588,21 @@  discard block
 block discarded – undo
588 588
 	    	}
589 589
 	    }
590 590
         */
591
-	}
591
+    }
592 592
 
593
-	/**
594
-	 *   	Show footer of page. Need this->emetteur object
593
+    /**
594
+     *   	Show footer of page. Need this->emetteur object
595 595
      *
596
-	 *   	@param	PDF			$pdf     			PDF
597
-	 * 		@param	Project		$object				Object to show
598
-	 *      @param	Translate	$outputlangs		Object lang for output
599
-	 *      @param	int			$hidefreetext		1=Hide free text
600
-	 *      @return	integer
601
-	 */
602
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
603
-	{
604
-		global $conf;
605
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
607
-	}
596
+     *   	@param	PDF			$pdf     			PDF
597
+     * 		@param	Project		$object				Object to show
598
+     *      @param	Translate	$outputlangs		Object lang for output
599
+     *      @param	int			$hidefreetext		1=Hide free text
600
+     *      @return	integer
601
+     */
602
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
603
+    {
604
+        global $conf;
605
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
+        return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
607
+    }
608 608
 }
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function __construct($db)
52 52
 	{
53
-		global $conf,$langs,$mysoc;
53
+		global $conf, $langs, $mysoc;
54 54
 
55 55
 		// Translations
56 56
 		$langs->loadLangs(array("main", "projects", "companies"));
@@ -61,38 +61,38 @@  discard block
 block discarded – undo
61 61
 
62 62
 		// Dimension page pour format A4
63 63
 		$this->type = 'pdf';
64
-		$formatarray=pdf_getFormat();
64
+		$formatarray = pdf_getFormat();
65 65
 		$this->page_largeur = $formatarray['width'];
66 66
 		$this->page_hauteur = $formatarray['height'];
67
-		$this->format = array($this->page_largeur,$this->page_hauteur);
68
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
69
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
70
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
71
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
67
+		$this->format = array($this->page_largeur, $this->page_hauteur);
68
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
69
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
70
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
71
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
72 72
 
73
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
74
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
75
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
73
+		$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
74
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
75
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
76 76
 
77 77
 		// Recupere emmetteur
78
-		$this->emetteur=$mysoc;
79
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
78
+		$this->emetteur = $mysoc;
79
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
80 80
 
81 81
 		// Defini position des colonnes
82
-		$this->posxref=$this->marge_gauche+1;
83
-		$this->posxlabel=$this->marge_gauche+25;
84
-		$this->posxtimespent=$this->marge_gauche+120;
82
+		$this->posxref = $this->marge_gauche + 1;
83
+		$this->posxlabel = $this->marge_gauche + 25;
84
+		$this->posxtimespent = $this->marge_gauche + 120;
85 85
 		//$this->posxprogress=$this->marge_gauche+140;
86
-		$this->posxdatestart=$this->marge_gauche+152;
87
-		$this->posxdateend=$this->marge_gauche+170;
86
+		$this->posxdatestart = $this->marge_gauche + 152;
87
+		$this->posxdateend = $this->marge_gauche + 170;
88 88
 		if ($this->page_largeur < 210) // To work with US executive format
89 89
 		{
90
-			$this->posxref-=20;
91
-			$this->posxlabel-=20;
92
-			$this->posxtimespent-=20;
90
+			$this->posxref -= 20;
91
+			$this->posxlabel -= 20;
92
+			$this->posxtimespent -= 20;
93 93
 			//$this->posxprogress-=20;
94
-			$this->posxdatestart-=20;
95
-			$this->posxdateend-=20;
94
+			$this->posxdatestart -= 20;
95
+			$this->posxdateend -= 20;
96 96
 		}
97 97
 	}
98 98
 
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 *	@param	Translate	$outputlangs	Lang output object
106 106
 	 *	@return	int         				1 if OK, <=0 if KO
107 107
 	 */
108
-	function write_file($object,$outputlangs)
108
+	function write_file($object, $outputlangs)
109 109
 	{
110 110
         // phpcs:enable
111 111
 		global $conf, $hookmanager, $langs, $user;
112 112
 
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
113
+		if (!is_object($outputlangs)) $outputlangs = $langs;
114 114
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
115
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
116 116
 
117 117
 		// Load traductions files requiredby by page
118 118
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 			$objectref = dol_sanitizeFileName($object->ref);
125 125
 			$dir = $conf->projet->dir_output;
126
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
127
-			$file = $dir . "/" . $objectref . ".pdf";
126
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
127
+			$file = $dir."/".$objectref.".pdf";
128 128
 
129
-			if (! file_exists($dir))
129
+			if (!file_exists($dir))
130 130
 			{
131 131
 				if (dol_mkdir($dir) < 0)
132 132
 				{
133
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
133
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
134 134
 					return 0;
135 135
 				}
136 136
 			}
@@ -138,24 +138,24 @@  discard block
 block discarded – undo
138 138
 			if (file_exists($dir))
139 139
 			{
140 140
 				// Add pdfgeneration hook
141
-				if (! is_object($hookmanager))
141
+				if (!is_object($hookmanager))
142 142
 				{
143 143
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
144
-					$hookmanager=new HookManager($this->db);
144
+					$hookmanager = new HookManager($this->db);
145 145
 				}
146 146
 				$hookmanager->initHooks(array('pdfgeneration'));
147
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
147
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
148 148
 				global $action;
149
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
149
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
150 150
 
151 151
 				// Create pdf instance
152
-				$pdf=pdf_getInstance($this->format);
153
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
154
-				$pdf->SetAutoPageBreak(1,0);
152
+				$pdf = pdf_getInstance($this->format);
153
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
154
+				$pdf->SetAutoPageBreak(1, 0);
155 155
 
156
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
157
-		        $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
158
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
156
+				$heightforinfotot = 40; // Height reserved to output the info and total part
157
+		        $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
158
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
159 159
 
160 160
                 if (class_exists('TCPDF'))
161 161
                 {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 }
165 165
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
166 166
                 // Set path to the background PDF File
167
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
167
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
168 168
                 {
169 169
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
170 170
                     $tplidx = $pdf->importPage(1);
@@ -172,68 +172,68 @@  discard block
 block discarded – undo
172 172
 
173 173
 				// Complete object by loading several other informations
174 174
 				$task = new Task($this->db);
175
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
175
+				$tasksarray = $task->getTasksArray(0, 0, $object->id);
176 176
 
177
-                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
177
+                if (!$object->id > 0)  // Special case when used with object = specimen, we may return all lines
178 178
                 {
179
-                    $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
179
+                    $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
180 180
                 }
181 181
 
182
-				$object->lines=$tasksarray;
183
-				$nblignes=count($object->lines);
182
+				$object->lines = $tasksarray;
183
+				$nblignes = count($object->lines);
184 184
 
185 185
 				$pdf->Open();
186
-				$pagenb=0;
187
-				$pdf->SetDrawColor(128,128,128);
186
+				$pagenb = 0;
187
+				$pdf->SetDrawColor(128, 128, 128);
188 188
 
189 189
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
190 190
 				$pdf->SetSubject($outputlangs->transnoentities("Project"));
191 191
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
192 192
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193 193
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
194
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
195 195
 
196
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
196
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
197 197
 
198 198
 				// New page
199 199
 				$pdf->AddPage();
200
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
200
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
201 201
 				$pagenb++;
202 202
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
203
-				$pdf->SetFont('','', $default_font_size - 1);
204
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
205
-				$pdf->SetTextColor(0,0,0);
203
+				$pdf->SetFont('', '', $default_font_size - 1);
204
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
205
+				$pdf->SetTextColor(0, 0, 0);
206 206
 
207 207
 				$tab_top = 50;
208
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
208
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
209 209
 				$tab_height = 170;
210 210
 				$tab_height_newpage = 190;
211 211
 
212 212
 				// Show public note
213
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
213
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
214 214
 				if ($notetoshow)
215 215
 				{
216
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
216
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
217 217
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
218 218
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
219 219
 
220 220
 					$tab_top -= 2;
221 221
 
222
-					$pdf->SetFont('','', $default_font_size - 1);
223
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
222
+					$pdf->SetFont('', '', $default_font_size - 1);
223
+					$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
224 224
 					$nexY = $pdf->GetY();
225
-					$height_note=$nexY-$tab_top;
225
+					$height_note = $nexY - $tab_top;
226 226
 
227 227
 					// Rect prend une longueur en 3eme param
228
-					$pdf->SetDrawColor(192,192,192);
229
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
228
+					$pdf->SetDrawColor(192, 192, 192);
229
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
230 230
 
231 231
 					$tab_height = $tab_height - $height_note;
232
-					$tab_top = $nexY+6;
232
+					$tab_top = $nexY + 6;
233 233
 				}
234 234
 				else
235 235
 				{
236
-					$height_note=0;
236
+					$height_note = 0;
237 237
 				}
238 238
 
239 239
 				$heightoftitleline = 10;
@@ -242,81 +242,81 @@  discard block
 block discarded – undo
242 242
 				$nexY = $tab_top + $heightoftitleline + 1;
243 243
 
244 244
 				// Loop on each lines
245
-				for ($i = 0 ; $i < $nblignes ; $i++)
245
+				for ($i = 0; $i < $nblignes; $i++)
246 246
 				{
247 247
 					$curY = $nexY;
248
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
249
-					$pdf->SetTextColor(0,0,0);
248
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
249
+					$pdf->SetTextColor(0, 0, 0);
250 250
 
251 251
 					$pdf->setTopMargin($tab_top_newpage);
252
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
253
-					$pageposbefore=$pdf->getPage();
252
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
253
+					$pageposbefore = $pdf->getPage();
254 254
 
255 255
 					// Description of line
256
-					$ref=$object->lines[$i]->ref;
257
-					$libelleline=$object->lines[$i]->label;
256
+					$ref = $object->lines[$i]->ref;
257
+					$libelleline = $object->lines[$i]->label;
258 258
 					//$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
259
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
260
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
261
-					$planned_timespent=convertSecondToTime((int) $object->lines[$i]->planned_timespent,'allhourmin');
259
+					$datestart = dol_print_date($object->lines[$i]->date_start, 'day');
260
+					$dateend = dol_print_date($object->lines[$i]->date_end, 'day');
261
+					$planned_timespent = convertSecondToTime((int) $object->lines[$i]->planned_timespent, 'allhourmin');
262 262
 
263
-					$showpricebeforepagebreak=1;
263
+					$showpricebeforepagebreak = 1;
264 264
 
265 265
 					$pdf->startTransaction();
266 266
 					// Label
267 267
 					$pdf->SetXY($this->posxlabel, $curY);
268
-					$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
-					$pageposafter=$pdf->getPage();
268
+					$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
+					$pageposafter = $pdf->getPage();
270 270
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
271 271
 					{
272 272
 						$pdf->rollbackTransaction(true);
273
-						$pageposafter=$pageposbefore;
273
+						$pageposafter = $pageposbefore;
274 274
 						//print $pageposafter.'-'.$pageposbefore;exit;
275
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
275
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
276 276
 						// Label
277 277
 						$pdf->SetXY($this->posxlabel, $curY);
278
-						$posybefore=$pdf->GetY();
279
-						$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
-						$pageposafter=$pdf->getPage();
281
-						$posyafter=$pdf->GetY();
282
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
278
+						$posybefore = $pdf->GetY();
279
+						$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
+						$pageposafter = $pdf->getPage();
281
+						$posyafter = $pdf->GetY();
282
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
283 283
 						{
284
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
284
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
285 285
 							{
286
-								$pdf->AddPage('','',true);
287
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
286
+								$pdf->AddPage('', '', true);
287
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
288 288
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
289
-								$pdf->setPage($pageposafter+1);
289
+								$pdf->setPage($pageposafter + 1);
290 290
 							}
291 291
 						}
292 292
 						else
293 293
 						{
294 294
 							// We found a page break
295
-							$showpricebeforepagebreak=0;
296
-							$forcedesconsamepage=1;
295
+							$showpricebeforepagebreak = 0;
296
+							$forcedesconsamepage = 1;
297 297
 							if ($forcedesconsamepage)
298 298
 							{
299 299
 								$pdf->rollbackTransaction(true);
300
-								$pageposafter=$pageposbefore;
301
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
300
+								$pageposafter = $pageposbefore;
301
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
302 302
 
303
-								$pdf->AddPage('','',true);
304
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
303
+								$pdf->AddPage('', '', true);
304
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
305 305
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
-								$pdf->setPage($pageposafter+1);
307
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
309
-								$pdf->SetTextColor(0,0,0);
306
+								$pdf->setPage($pageposafter + 1);
307
+								$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
308
+								$pdf->MultiCell(0, 3, ''); // Set interline to 3
309
+								$pdf->SetTextColor(0, 0, 0);
310 310
 
311
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
311
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
312 312
 								$curY = $tab_top_newpage + $heightoftitleline + 1;
313 313
 
314 314
 								// Label
315 315
 								$pdf->SetXY($this->posxlabel, $curY);
316
-								$posybefore=$pdf->GetY();
317
-								$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
-								$pageposafter=$pdf->getPage();
319
-								$posyafter=$pdf->GetY();
316
+								$posybefore = $pdf->GetY();
317
+								$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
+								$pageposafter = $pdf->getPage();
319
+								$posyafter = $pdf->GetY();
320 320
 							}
321 321
 						}
322 322
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
 					{
326 326
 						$pdf->commitTransaction();
327 327
 					}
328
-					$posYAfterDescription=$pdf->GetY();
328
+					$posYAfterDescription = $pdf->GetY();
329 329
 
330 330
 					$nexY = $pdf->GetY();
331
-					$pageposafter=$pdf->getPage();
331
+					$pageposafter = $pdf->getPage();
332 332
 					$pdf->setPage($pageposbefore);
333 333
 					$pdf->setTopMargin($this->marge_haute);
334
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
334
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
335 335
 
336 336
 					// We suppose that a too long description is moved completely on next page
337 337
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -339,34 +339,34 @@  discard block
 block discarded – undo
339 339
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
340 340
 					}
341 341
 
342
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
342
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
343 343
 
344 344
 					// Ref of task
345 345
 					$pdf->SetXY($this->posxref, $curY);
346
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
346
+					$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
347 347
 					// timespent
348 348
 					$pdf->SetXY($this->posxtimespent, $curY);
349
-					$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $planned_timespent?$planned_timespent:'', 0, 'R');
349
+					$pdf->MultiCell($this->posxdatestart - $this->posxtimespent, 3, $planned_timespent ? $planned_timespent : '', 0, 'R');
350 350
 					// Progress
351 351
 					//$pdf->SetXY($this->posxprogress, $curY);
352 352
 					//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
353 353
 					// Date
354 354
 					$pdf->SetXY($this->posxdatestart, $curY);
355
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
355
+					$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
356 356
 					$pdf->SetXY($this->posxdateend, $curY);
357
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
357
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
358 358
 
359 359
 					// Add line
360
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
360
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361 361
 					{
362 362
 						$pdf->setPage($pageposafter);
363
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
363
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
364 364
 						//$pdf->SetDrawColor(190,190,200);
365
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
365
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
366 366
 						$pdf->SetLineStyle(array('dash'=>0));
367 367
 					}
368 368
 
369
-					$nexY+=2;    // Passe espace entre les lignes
369
+					$nexY += 2; // Passe espace entre les lignes
370 370
 
371 371
 					// Detect if some page were added automatically and output _tableau for past pages
372 372
 					while ($pagenb < $pageposafter)
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 						{
381 381
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382 382
 						}
383
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
383
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
384 384
 						$pagenb++;
385 385
 						$pdf->setPage($pagenb);
386
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
386
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
387 387
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388 388
 					}
389
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
389
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
390 390
 					{
391 391
 						if ($pagenb == 1)
392 392
 						{
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
 						{
397 397
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398 398
 						}
399
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
399
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
400 400
 						// New page
401 401
 						$pdf->AddPage();
402
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
402
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
403 403
 						$pagenb++;
404 404
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405 405
 					}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411 411
 				else
412 412
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
413
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
413
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414 414
 
415 415
 				// Pied de page
416 416
 				$this->_pagefoot($pdf, $object, $outputlangs);
@@ -422,26 +422,26 @@  discard block
 block discarded – undo
422 422
 
423 423
 				// Add pdfgeneration hook
424 424
 				$hookmanager->initHooks(array('pdfgeneration'));
425
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
425
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
426 426
 				global $action;
427
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
427
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
428 428
 
429
-				if (! empty($conf->global->MAIN_UMASK))
429
+				if (!empty($conf->global->MAIN_UMASK))
430 430
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
431 431
 
432 432
 				$this->result = array('fullpath'=>$file);
433 433
 
434
-				return 1;   // Pas d'erreur
434
+				return 1; // Pas d'erreur
435 435
 			}
436 436
 			else
437 437
 			{
438
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
438
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
439 439
 				return 0;
440 440
 			}
441 441
 		}
442 442
 		else
443 443
 		{
444
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
444
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
445 445
 			return 0;
446 446
 		}
447 447
 	}
@@ -459,41 +459,41 @@  discard block
 block discarded – undo
459 459
 	 *   @param		int			$hidebottom		Hide bottom bar of array
460 460
 	 *   @return	void
461 461
 	 */
462
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
462
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
463 463
 	{
464
-		global $conf,$mysoc;
464
+		global $conf, $mysoc;
465 465
 
466 466
 		$heightoftitleline = 10;
467 467
 
468 468
         $default_font_size = pdf_getPDFFontSize($outputlangs);
469 469
 
470
-		$pdf->SetDrawColor(128,128,128);
470
+		$pdf->SetDrawColor(128, 128, 128);
471 471
 
472 472
 		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
473
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
473
+		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
474 474
 
475 475
 		// line prend une position y en 3eme param
476
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
476
+		$pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
477 477
 
478
-		$pdf->SetTextColor(0,0,0);
479
-		$pdf->SetFont('','', $default_font_size);
478
+		$pdf->SetTextColor(0, 0, 0);
479
+		$pdf->SetFont('', '', $default_font_size);
480 480
 
481
-		$pdf->SetXY($this->posxref, $tab_top+1);
482
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
481
+		$pdf->SetXY($this->posxref, $tab_top + 1);
482
+		$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
483 483
 
484
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
485
-		$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
484
+		$pdf->SetXY($this->posxlabel, $tab_top + 1);
485
+		$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
486 486
 
487
-		$pdf->SetXY($this->posxtimespent, $tab_top+1);
488
-		$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
487
+		$pdf->SetXY($this->posxtimespent, $tab_top + 1);
488
+		$pdf->MultiCell($this->posxdatestart - $this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
489 489
 
490 490
 		//$pdf->SetXY($this->posxprogress, $tab_top+1);
491 491
 		//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
492 492
 
493
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
494
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
493
+		$pdf->SetXY($this->posxdatestart, $tab_top + 1);
494
+		$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
495 495
 
496
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
496
+		$pdf->SetXY($this->posxdateend, $tab_top + 1);
497 497
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
498 498
 	}
499 499
 
@@ -508,62 +508,62 @@  discard block
 block discarded – undo
508 508
 	 */
509 509
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
510 510
 	{
511
-		global $langs,$conf,$mysoc;
511
+		global $langs, $conf, $mysoc;
512 512
 
513 513
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
514 514
 
515
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
515
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
516 516
 
517
-		$pdf->SetTextColor(0,0,60);
518
-		$pdf->SetFont('','B', $default_font_size + 3);
517
+		$pdf->SetTextColor(0, 0, 60);
518
+		$pdf->SetFont('', 'B', $default_font_size + 3);
519 519
 
520
-        $posx=$this->page_largeur-$this->marge_droite-100;
521
-		$posy=$this->marge_haute;
520
+        $posx = $this->page_largeur - $this->marge_droite - 100;
521
+		$posy = $this->marge_haute;
522 522
 
523
-		$pdf->SetXY($this->marge_gauche,$posy);
523
+		$pdf->SetXY($this->marge_gauche, $posy);
524 524
 
525 525
 		// Logo
526
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
526
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
527 527
 		if ($mysoc->logo)
528 528
 		{
529 529
 			if (is_readable($logo))
530 530
 			{
531
-			    $height=pdf_getHeightForLogo($logo);
532
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
531
+			    $height = pdf_getHeightForLogo($logo);
532
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
533 533
 			}
534 534
 			else
535 535
 			{
536
-				$pdf->SetTextColor(200,0,0);
537
-				$pdf->SetFont('','B', $default_font_size - 2);
538
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
536
+				$pdf->SetTextColor(200, 0, 0);
537
+				$pdf->SetFont('', 'B', $default_font_size - 2);
538
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
539 539
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540 540
 			}
541 541
 		}
542 542
 		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543 543
 
544
-		$pdf->SetFont('','B', $default_font_size + 3);
545
-		$pdf->SetXY($posx,$posy);
546
-		$pdf->SetTextColor(0,0,60);
544
+		$pdf->SetFont('', 'B', $default_font_size + 3);
545
+		$pdf->SetXY($posx, $posy);
546
+		$pdf->SetTextColor(0, 0, 60);
547 547
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
548
-		$pdf->SetFont('','', $default_font_size + 2);
548
+		$pdf->SetFont('', '', $default_font_size + 2);
549 549
 
550
-		$posy+=6;
551
-		$pdf->SetXY($posx,$posy);
552
-		$pdf->SetTextColor(0,0,60);
553
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
550
+		$posy += 6;
551
+		$pdf->SetXY($posx, $posy);
552
+		$pdf->SetTextColor(0, 0, 60);
553
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
554 554
 
555
-		$posy+=6;
556
-		$pdf->SetXY($posx,$posy);
557
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
555
+		$posy += 6;
556
+		$pdf->SetXY($posx, $posy);
557
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
558 558
 
559 559
 		if (is_object($object->thirdparty))
560 560
 		{
561
-			$posy+=6;
562
-			$pdf->SetXY($posx,$posy);
563
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
561
+			$posy += 6;
562
+			$pdf->SetXY($posx, $posy);
563
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
564 564
 		}
565 565
 
566
-		$pdf->SetTextColor(0,0,60);
566
+		$pdf->SetTextColor(0, 0, 60);
567 567
 
568 568
 		// Add list of linked objects
569 569
 		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 	 *      @param	int			$hidefreetext		1=Hide free text
600 600
 	 *      @return	integer
601 601
 	 */
602
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
602
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
603 603
 	{
604 604
 		global $conf;
605
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
605
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
+		return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
607 607
 	}
608 608
 }
Please login to merge, or discard this patch.
Braces   +73 added lines, -41 removed lines patch added patch discarded remove patch
@@ -76,7 +76,10 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Recupere emmetteur
78 78
 		$this->emetteur=$mysoc;
79
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
79
+		if (! $this->emetteur->country_code) {
80
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
81
+		}
82
+		// By default if not defined
80 83
 
81 84
 		// Defini position des colonnes
82 85
 		$this->posxref=$this->marge_gauche+1;
@@ -85,9 +88,11 @@  discard block
 block discarded – undo
85 88
 		//$this->posxprogress=$this->marge_gauche+140;
86 89
 		$this->posxdatestart=$this->marge_gauche+152;
87 90
 		$this->posxdateend=$this->marge_gauche+170;
88
-		if ($this->page_largeur < 210) // To work with US executive format
91
+		if ($this->page_largeur < 210) {
92
+		    // To work with US executive format
89 93
 		{
90 94
 			$this->posxref-=20;
95
+		}
91 96
 			$this->posxlabel-=20;
92 97
 			$this->posxtimespent-=20;
93 98
 			//$this->posxprogress-=20;
@@ -110,9 +115,13 @@  discard block
 block discarded – undo
110 115
         // phpcs:enable
111 116
 		global $conf, $hookmanager, $langs, $user;
112 117
 
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
118
+		if (! is_object($outputlangs)) {
119
+		    $outputlangs=$langs;
120
+		}
114 121
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
122
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
123
+		    $outputlangs->charset_output='ISO-8859-1';
124
+		}
116 125
 
117 126
 		// Load traductions files requiredby by page
118 127
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -123,7 +132,9 @@  discard block
 block discarded – undo
123 132
 
124 133
 			$objectref = dol_sanitizeFileName($object->ref);
125 134
 			$dir = $conf->projet->dir_output;
126
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
135
+			if (! preg_match('/specimen/i',$objectref)) {
136
+			    $dir.= "/" . $objectref;
137
+			}
127 138
 			$file = $dir . "/" . $objectref . ".pdf";
128 139
 
129 140
 			if (! file_exists($dir))
@@ -174,10 +185,12 @@  discard block
 block discarded – undo
174 185
 				$task = new Task($this->db);
175 186
 				$tasksarray = $task->getTasksArray(0,0,$object->id);
176 187
 
177
-                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
188
+                if (! $object->id > 0) {
189
+                    // Special case when used with object = specimen, we may return all lines
178 190
                 {
179 191
                     $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
180 192
                 }
193
+                }
181 194
 
182 195
 				$object->lines=$tasksarray;
183 196
 				$nblignes=count($object->lines);
@@ -191,13 +204,17 @@  discard block
 block discarded – undo
191 204
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
192 205
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193 206
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
207
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
208
+				    $pdf->SetCompression(false);
209
+				}
195 210
 
196 211
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
197 212
 
198 213
 				// New page
199 214
 				$pdf->AddPage();
200
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
215
+				if (! empty($tplidx)) {
216
+				    $pdf->useTemplate($tplidx);
217
+				}
201 218
 				$pagenb++;
202 219
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
203 220
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -230,8 +247,7 @@  discard block
 block discarded – undo
230 247
 
231 248
 					$tab_height = $tab_height - $height_note;
232 249
 					$tab_top = $nexY+6;
233
-				}
234
-				else
250
+				} else
235 251
 				{
236 252
 					$height_note=0;
237 253
 				}
@@ -267,9 +283,11 @@  discard block
 block discarded – undo
267 283
 					$pdf->SetXY($this->posxlabel, $curY);
268 284
 					$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269 285
 					$pageposafter=$pdf->getPage();
270
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
286
+					if ($pageposafter > $pageposbefore) {
287
+					    // There is a pagebreak
271 288
 					{
272 289
 						$pdf->rollbackTransaction(true);
290
+					}
273 291
 						$pageposafter=$pageposbefore;
274 292
 						//print $pageposafter.'-'.$pageposbefore;exit;
275 293
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -279,17 +297,22 @@  discard block
 block discarded – undo
279 297
 						$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280 298
 						$pageposafter=$pdf->getPage();
281 299
 						$posyafter=$pdf->GetY();
282
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
300
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
301
+						    // There is no space left for total+free text
283 302
 						{
284 303
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
285 304
 							{
286 305
 								$pdf->AddPage('','',true);
287
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
+						}
307
+								if (! empty($tplidx)) {
308
+								    $pdf->useTemplate($tplidx);
309
+								}
310
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
311
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
312
+								}
289 313
 								$pdf->setPage($pageposafter+1);
290 314
 							}
291
-						}
292
-						else
315
+						} else
293 316
 						{
294 317
 							// We found a page break
295 318
 							$showpricebeforepagebreak=0;
@@ -301,8 +324,12 @@  discard block
 block discarded – undo
301 324
 								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
302 325
 
303 326
 								$pdf->AddPage('','',true);
304
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
305
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
327
+								if (! empty($tplidx)) {
328
+								    $pdf->useTemplate($tplidx);
329
+								}
330
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
331
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
332
+								}
306 333
 								$pdf->setPage($pageposafter+1);
307 334
 								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308 335
 								$pdf->MultiCell(0, 3, '');		// Set interline to 3
@@ -320,8 +347,7 @@  discard block
 block discarded – undo
320 347
 							}
321 348
 						}
322 349
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
323
-					}
324
-					else	// No pagebreak
350
+					} else	// No pagebreak
325 351
 					{
326 352
 						$pdf->commitTransaction();
327 353
 					}
@@ -375,8 +401,7 @@  discard block
 block discarded – undo
375 401
 						if ($pagenb == 1)
376 402
 						{
377 403
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378
-						}
379
-						else
404
+						} else
380 405
 						{
381 406
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382 407
 						}
@@ -384,37 +409,45 @@  discard block
 block discarded – undo
384 409
 						$pagenb++;
385 410
 						$pdf->setPage($pagenb);
386 411
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
412
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
413
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
414
+						}
388 415
 					}
389 416
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390 417
 					{
391 418
 						if ($pagenb == 1)
392 419
 						{
393 420
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394
-						}
395
-						else
421
+						} else
396 422
 						{
397 423
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398 424
 						}
399 425
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
400 426
 						// New page
401 427
 						$pdf->AddPage();
402
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
428
+						if (! empty($tplidx)) {
429
+						    $pdf->useTemplate($tplidx);
430
+						}
403 431
 						$pagenb++;
404
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
432
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
433
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
434
+						}
405 435
 					}
406 436
 				}
407 437
 
408 438
 				// Show square
409
-				if ($pagenb == 1)
410
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411
-				else
412
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
439
+				if ($pagenb == 1) {
440
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
441
+				} else {
442
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
443
+				}
413 444
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414 445
 
415 446
 				// Pied de page
416 447
 				$this->_pagefoot($pdf, $object, $outputlangs);
417
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
448
+				if (method_exists($pdf, 'AliasNbPages')) {
449
+				    $pdf->AliasNbPages();
450
+				}
418 451
 
419 452
 				$pdf->Close();
420 453
 
@@ -426,20 +459,19 @@  discard block
 block discarded – undo
426 459
 				global $action;
427 460
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
428 461
 
429
-				if (! empty($conf->global->MAIN_UMASK))
430
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
462
+				if (! empty($conf->global->MAIN_UMASK)) {
463
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
464
+				}
431 465
 
432 466
 				$this->result = array('fullpath'=>$file);
433 467
 
434 468
 				return 1;   // Pas d'erreur
435
-			}
436
-			else
469
+			} else
437 470
 			{
438 471
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
439 472
 				return 0;
440 473
 			}
441
-		}
442
-		else
474
+		} else
443 475
 		{
444 476
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
445 477
 			return 0;
@@ -530,16 +562,16 @@  discard block
 block discarded – undo
530 562
 			{
531 563
 			    $height=pdf_getHeightForLogo($logo);
532 564
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
533
-			}
534
-			else
565
+			} else
535 566
 			{
536 567
 				$pdf->SetTextColor(200,0,0);
537 568
 				$pdf->SetFont('','B', $default_font_size - 2);
538 569
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
539 570
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540 571
 			}
572
+		} else {
573
+		    $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
541 574
 		}
542
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543 575
 
544 576
 		$pdf->SetFont('','B', $default_font_size + 3);
545 577
 		$pdf->SetXY($posx,$posy);
Please login to merge, or discard this patch.
htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php 3 patches
Indentation   +1110 added lines, -1110 removed lines patch added patch discarded remove patch
@@ -54,85 +54,85 @@  discard block
 block discarded – undo
54 54
  */
55 55
 class doc_generic_project_odt extends ModelePDFProjects
56 56
 {
57
-	/**
58
-	 * Issuer
59
-	 * @var Societe
60
-	 */
61
-	public $emetteur;
57
+    /**
58
+     * Issuer
59
+     * @var Societe
60
+     */
61
+    public $emetteur;
62 62
 
63
-	/**
63
+    /**
64 64
      * @var array() Minimum version of PHP required by module.
65
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
65
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
66 66
      */
67
-	public $phpmin = array(5, 4);
67
+    public $phpmin = array(5, 4);
68 68
 
69
-	/**
69
+    /**
70 70
      * Dolibarr version of the loaded document
71 71
      * @public string
72 72
      */
73
-	public $version = 'dolibarr';
74
-
75
-
76
-	/**
77
-	 *	Constructor
78
-	 *
79
-	 *  @param		DoliDB		$db      Database handler
80
-	 */
81
-	function __construct($db)
82
-	{
83
-		global $conf, $langs, $mysoc;
84
-
85
-		// Load traductions files requiredby by page
86
-		$langs->loadLangs(array("companies", "main"));
87
-
88
-		$this->db = $db;
89
-		$this->name = "ODT templates";
90
-		$this->description = $langs->trans("DocumentModelOdt");
91
-		$this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
92
-
93
-		// Dimension page pour format A4
94
-		$this->type = 'odt';
95
-		$this->page_largeur = 0;
96
-		$this->page_hauteur = 0;
97
-		$this->format = array($this->page_largeur,$this->page_hauteur);
98
-		$this->marge_gauche=0;
99
-		$this->marge_droite=0;
100
-		$this->marge_haute=0;
101
-		$this->marge_basse=0;
102
-
103
-		$this->option_logo = 1;                    // Affiche logo
104
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
105
-		$this->option_modereg = 0;                 // Affiche mode reglement
106
-		$this->option_condreg = 0;                 // Affiche conditions reglement
107
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
108
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
109
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
110
-		$this->option_credit_note = 0;             // Support credit notes
111
-		$this->option_freetext = 1;				   // Support add of a personalised text
112
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
113
-
114
-		// Recupere emetteur
115
-		$this->emetteur=$mysoc;
116
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
117
-	}
73
+    public $version = 'dolibarr';
74
+
75
+
76
+    /**
77
+     *	Constructor
78
+     *
79
+     *  @param		DoliDB		$db      Database handler
80
+     */
81
+    function __construct($db)
82
+    {
83
+        global $conf, $langs, $mysoc;
84
+
85
+        // Load traductions files requiredby by page
86
+        $langs->loadLangs(array("companies", "main"));
87
+
88
+        $this->db = $db;
89
+        $this->name = "ODT templates";
90
+        $this->description = $langs->trans("DocumentModelOdt");
91
+        $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
92
+
93
+        // Dimension page pour format A4
94
+        $this->type = 'odt';
95
+        $this->page_largeur = 0;
96
+        $this->page_hauteur = 0;
97
+        $this->format = array($this->page_largeur,$this->page_hauteur);
98
+        $this->marge_gauche=0;
99
+        $this->marge_droite=0;
100
+        $this->marge_haute=0;
101
+        $this->marge_basse=0;
102
+
103
+        $this->option_logo = 1;                    // Affiche logo
104
+        $this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
105
+        $this->option_modereg = 0;                 // Affiche mode reglement
106
+        $this->option_condreg = 0;                 // Affiche conditions reglement
107
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
108
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
109
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
110
+        $this->option_credit_note = 0;             // Support credit notes
111
+        $this->option_freetext = 1;				   // Support add of a personalised text
112
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
113
+
114
+        // Recupere emetteur
115
+        $this->emetteur=$mysoc;
116
+        if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
117
+    }
118 118
 
119 119
 
120 120
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
121
-	/**
122
-	 * Define array with couple substitution key => substitution value
123
-	 *
124
-	 * @param   Project			$object             Main object to use as data source
125
-	 * @param   Translate		$outputlangs        Lang object to use for output
121
+    /**
122
+     * Define array with couple substitution key => substitution value
123
+     *
124
+     * @param   Project			$object             Main object to use as data source
125
+     * @param   Translate		$outputlangs        Lang object to use for output
126 126
      * @param   string		    $array_key	        Name of the key for return array
127
-	 * @return	array								Array of substitution
128
-	 */
129
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130
-	{
127
+     * @return	array								Array of substitution
128
+     */
129
+    function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130
+    {
131 131
         // phpcs:enable
132
-		global $conf;
132
+        global $conf;
133 133
 
134
-		$resarray=array(
135
-		    $array_key.'_id'=>$object->id,
134
+        $resarray=array(
135
+            $array_key.'_id'=>$object->id,
136 136
             $array_key.'_ref'=>$object->ref,
137 137
             $array_key.'_title'=>$object->title,
138 138
             $array_key.'_description'=>$object->description,
@@ -144,1086 +144,1086 @@  discard block
 block discarded – undo
144 144
             $array_key.'_note_public'=>$object->note_public,
145 145
             $array_key.'_public'=>$object->public,
146 146
             $array_key.'_statut'=>$object->getLibStatut()
147
-		);
147
+        );
148 148
 
149
-		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150
-		$extrafields = new ExtraFields($this->db);
151
-		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
152
-		$object->fetch_optionals();
149
+        require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150
+        $extrafields = new ExtraFields($this->db);
151
+        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
152
+        $object->fetch_optionals();
153 153
 
154
-		$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
154
+        $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
155 155
 
156
-		return $resarray;
157
-	}
156
+        return $resarray;
157
+    }
158 158
 
159 159
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
160
-	/**
161
-	 *	Define array with couple substitution key => substitution value
162
-	 *
163
-	 *	@param  array			$task				Task Object
164
-	 *	@param  Translate		$outputlangs        Lang object to use for output
165
-	 *  @return	array								Return a substitution array
166
-	 */
167
-	function get_substitutionarray_tasks(Task $task,$outputlangs)
168
-	{
160
+    /**
161
+     *	Define array with couple substitution key => substitution value
162
+     *
163
+     *	@param  array			$task				Task Object
164
+     *	@param  Translate		$outputlangs        Lang object to use for output
165
+     *  @return	array								Return a substitution array
166
+     */
167
+    function get_substitutionarray_tasks(Task $task,$outputlangs)
168
+    {
169 169
         // phpcs:enable
170
-		global $conf;
171
-
172
-		$resarray = array(
173
-			'task_ref'=>$task->ref,
174
-			'task_fk_project'=>$task->fk_project,
175
-			'task_projectref'=>$task->projectref,
176
-			'task_projectlabel'=>$task->projectlabel,
177
-			'task_label'=>$task->label,
178
-			'task_description'=>$task->description,
179
-			'task_fk_parent'=>$task->fk_parent,
180
-			'task_duration'=>$task->duration,
181
-			'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
182
-			'task_progress'=>$task->progress,
183
-			'task_public'=>$task->public,
184
-			'task_date_start'=>dol_print_date($task->date_start,'day'),
185
-			'task_date_end'=>dol_print_date($task->date_end,'day'),
186
-			'task_note_private'=>$task->note_private,
187
-			'task_note_public'=>$task->note_public
188
-		);
189
-
190
-		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191
-		$extrafields = new ExtraFields($this->db);
192
-		$extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193
-		$task->fetch_optionals($task->id,$extralabels);
194
-
195
-		$resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
196
-
197
-		return $resarray;
198
-	}
170
+        global $conf;
171
+
172
+        $resarray = array(
173
+            'task_ref'=>$task->ref,
174
+            'task_fk_project'=>$task->fk_project,
175
+            'task_projectref'=>$task->projectref,
176
+            'task_projectlabel'=>$task->projectlabel,
177
+            'task_label'=>$task->label,
178
+            'task_description'=>$task->description,
179
+            'task_fk_parent'=>$task->fk_parent,
180
+            'task_duration'=>$task->duration,
181
+            'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
182
+            'task_progress'=>$task->progress,
183
+            'task_public'=>$task->public,
184
+            'task_date_start'=>dol_print_date($task->date_start,'day'),
185
+            'task_date_end'=>dol_print_date($task->date_end,'day'),
186
+            'task_note_private'=>$task->note_private,
187
+            'task_note_public'=>$task->note_public
188
+        );
189
+
190
+        require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191
+        $extrafields = new ExtraFields($this->db);
192
+        $extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193
+        $task->fetch_optionals($task->id,$extralabels);
194
+
195
+        $resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
196
+
197
+        return $resarray;
198
+    }
199 199
 
200 200
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
201
-	/**
202
-	 *	Define array with couple substitution key => substitution value
203
-	 *
204
-	 *	@param  array			$contact			Contact array
205
-	 *	@param  Translate		$outputlangs        Lang object to use for output
206
-	 *  @return	array								Return a substitution array
207
-	 */
208
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
209
-	{
201
+    /**
202
+     *	Define array with couple substitution key => substitution value
203
+     *
204
+     *	@param  array			$contact			Contact array
205
+     *	@param  Translate		$outputlangs        Lang object to use for output
206
+     *  @return	array								Return a substitution array
207
+     */
208
+    function get_substitutionarray_project_contacts($contact,$outputlangs)
209
+    {
210 210
         // phpcs:enable
211
-		global $conf;
212
-		$pc='projcontacts_'; // prefix to avoid typos
213
-
214
-		$ret = array(
215
-			$pc.'id'=>$contact['id'],
216
-			$pc.'rowid'=>$contact['rowid'],
217
-			$pc.'role'=>$contact['libelle'],
218
-			$pc.'lastname'=>$contact['lastname'],
219
-			$pc.'firstname'=>$contact['firstname'],
220
-			$pc.'civility'=>$contact['civility'],
221
-			$pc.'fullcivname'=>$contact['fullname'],
222
-			$pc.'socname'=>$contact['socname'],
223
-			$pc.'email'=>$contact['email']
224
-			);
225
-
226
-		if ($contact['source']=='external') {
227
-			$ret[$pc.'isInternal'] = ''; // not internal
228
-
229
-			$ct = new Contact($this->db);
230
-			$ct->fetch($contact['id']);
231
-			$ret[$pc.'phone_pro'] = $ct->phone_pro;
232
-			$ret[$pc.'phone_perso'] = $ct->phone_perso;
233
-			$ret[$pc.'phone_mobile'] = $ct->phone_mobile;
234
-
235
-			// fetch external user extrafields
236
-			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237
-			$extrafields=new ExtraFields($this->db);
238
-			$extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
239
-			$extrafields_num = $ct->fetch_optionals();
240
-			//dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241
-			foreach($ct->array_options as $efkey => $efval) {
242
-				dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243
-				$ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244
-			}
245
-		} elseif ($contact['source']=='internal') {
246
-			$ret[$pc.'isInternal'] = '1'; // this is an internal user
247
-
248
-			$ct = new User($this->db);
249
-			$ct->fetch($contact['id']);
250
-			$ret[$pc.'phone_pro'] = $ct->office_phone;
251
-			$ret[$pc.'phone_perso'] = '';
252
-			$ret[$pc.'phone_mobile'] = $ct->user_mobile;
253
-			// do internal users have extrafields ?
254
-		}
255
-		return $ret;
256
-	}
211
+        global $conf;
212
+        $pc='projcontacts_'; // prefix to avoid typos
213
+
214
+        $ret = array(
215
+            $pc.'id'=>$contact['id'],
216
+            $pc.'rowid'=>$contact['rowid'],
217
+            $pc.'role'=>$contact['libelle'],
218
+            $pc.'lastname'=>$contact['lastname'],
219
+            $pc.'firstname'=>$contact['firstname'],
220
+            $pc.'civility'=>$contact['civility'],
221
+            $pc.'fullcivname'=>$contact['fullname'],
222
+            $pc.'socname'=>$contact['socname'],
223
+            $pc.'email'=>$contact['email']
224
+            );
225
+
226
+        if ($contact['source']=='external') {
227
+            $ret[$pc.'isInternal'] = ''; // not internal
228
+
229
+            $ct = new Contact($this->db);
230
+            $ct->fetch($contact['id']);
231
+            $ret[$pc.'phone_pro'] = $ct->phone_pro;
232
+            $ret[$pc.'phone_perso'] = $ct->phone_perso;
233
+            $ret[$pc.'phone_mobile'] = $ct->phone_mobile;
234
+
235
+            // fetch external user extrafields
236
+            require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237
+            $extrafields=new ExtraFields($this->db);
238
+            $extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
239
+            $extrafields_num = $ct->fetch_optionals();
240
+            //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241
+            foreach($ct->array_options as $efkey => $efval) {
242
+                dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243
+                $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244
+            }
245
+        } elseif ($contact['source']=='internal') {
246
+            $ret[$pc.'isInternal'] = '1'; // this is an internal user
247
+
248
+            $ct = new User($this->db);
249
+            $ct->fetch($contact['id']);
250
+            $ret[$pc.'phone_pro'] = $ct->office_phone;
251
+            $ret[$pc.'phone_perso'] = '';
252
+            $ret[$pc.'phone_mobile'] = $ct->user_mobile;
253
+            // do internal users have extrafields ?
254
+        }
255
+        return $ret;
256
+    }
257 257
 
258 258
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
259
-	/**
260
-	 *	Define array with couple substitution key => substitution value
261
-	 *
262
-	 *	@param  array			$file				file array
263
-	 *	@param  Translate		$outputlangs        Lang object to use for output
264
-	 *  @return	array								Return a substitution array
265
-	 */
266
-	function get_substitutionarray_project_file($file,$outputlangs)
267
-	{
259
+    /**
260
+     *	Define array with couple substitution key => substitution value
261
+     *
262
+     *	@param  array			$file				file array
263
+     *	@param  Translate		$outputlangs        Lang object to use for output
264
+     *  @return	array								Return a substitution array
265
+     */
266
+    function get_substitutionarray_project_file($file,$outputlangs)
267
+    {
268 268
         // phpcs:enable
269
-		global $conf;
269
+        global $conf;
270 270
 
271
-		return array(
272
-		'projfile_name'=>$file['name'],
273
-		'projfile_date'=>dol_print_date($file['date'],'day'),
274
-		'projfile_size'=>$file['size']
275
-		);
276
-	}
271
+        return array(
272
+        'projfile_name'=>$file['name'],
273
+        'projfile_date'=>dol_print_date($file['date'],'day'),
274
+        'projfile_size'=>$file['size']
275
+        );
276
+    }
277 277
 
278 278
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
279
-	/**
280
-	 *	Define array with couple substitution key => substitution value
281
-	 *
282
-	 *	@param  array			$refdetail			Reference array
283
-	 *	@param  Translate		$outputlangs        Lang object to use for output
284
-	 *  @return	array								Return a substitution array
285
-	 */
286
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
287
-	{
279
+    /**
280
+     *	Define array with couple substitution key => substitution value
281
+     *
282
+     *	@param  array			$refdetail			Reference array
283
+     *	@param  Translate		$outputlangs        Lang object to use for output
284
+     *  @return	array								Return a substitution array
285
+     */
286
+    function get_substitutionarray_project_reference($refdetail,$outputlangs)
287
+    {
288 288
         // phpcs:enable
289
-		global $conf;
290
-
291
-		return array(
292
-		'projref_type'=>$refdetail['type'],
293
-		'projref_ref'=>$refdetail['ref'],
294
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
295
-		'projref_socname'=>$refdetail['socname'],
296
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
298
-		'projref_status'=>$refdetail['status']
299
-		);
300
-	}
289
+        global $conf;
290
+
291
+        return array(
292
+        'projref_type'=>$refdetail['type'],
293
+        'projref_ref'=>$refdetail['ref'],
294
+        'projref_date'=>dol_print_date($refdetail['date'],'day'),
295
+        'projref_socname'=>$refdetail['socname'],
296
+        'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297
+        'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
298
+        'projref_status'=>$refdetail['status']
299
+        );
300
+    }
301 301
 
302 302
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
303
-	/**
304
-	 *	Define array with couple substitution key => substitution value
305
-	 *
306
-	 *	@param  array			$taskressource			Reference array
307
-	 *	@param  Translate		$outputlangs        Lang object to use for output
308
-	 *  @return	array								Return a substitution array
309
-	 */
310
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
311
-	{
303
+    /**
304
+     *	Define array with couple substitution key => substitution value
305
+     *
306
+     *	@param  array			$taskressource			Reference array
307
+     *	@param  Translate		$outputlangs        Lang object to use for output
308
+     *  @return	array								Return a substitution array
309
+     */
310
+    function get_substitutionarray_tasksressource($taskressource,$outputlangs)
311
+    {
312 312
         // phpcs:enable
313
-		global $conf;
314
-		//dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
315
-		return array(
316
-		'taskressource_rowid'=>$taskressource['rowid'],
317
-		'taskressource_role'=>$taskressource['libelle'],
318
-		'taskressource_lastname'=>$taskressource['lastname'],
319
-		'taskressource_firstname'=>$taskressource['firstname'],
320
-		'taskressource_fullcivname'=>$taskressource['fullname'],
321
-		'taskressource_socname'=>$taskressource['socname'],
322
-		'taskressource_email'=>$taskressource['email']
323
-		);
324
-	}
313
+        global $conf;
314
+        //dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
315
+        return array(
316
+        'taskressource_rowid'=>$taskressource['rowid'],
317
+        'taskressource_role'=>$taskressource['libelle'],
318
+        'taskressource_lastname'=>$taskressource['lastname'],
319
+        'taskressource_firstname'=>$taskressource['firstname'],
320
+        'taskressource_fullcivname'=>$taskressource['fullname'],
321
+        'taskressource_socname'=>$taskressource['socname'],
322
+        'taskressource_email'=>$taskressource['email']
323
+        );
324
+    }
325 325
 
326 326
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
327
-	/**
328
-	 *	Define array with couple substitution key => substitution value
329
-	 *
330
-	 *	@param  object			$tasktime			times object
331
-	 *	@param  Translate		$outputlangs        Lang object to use for output
332
-	 *  @return	array								Return a substitution array
333
-	 */
334
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
335
-	{
327
+    /**
328
+     *	Define array with couple substitution key => substitution value
329
+     *
330
+     *	@param  object			$tasktime			times object
331
+     *	@param  Translate		$outputlangs        Lang object to use for output
332
+     *  @return	array								Return a substitution array
333
+     */
334
+    function get_substitutionarray_taskstime($tasktime,$outputlangs)
335
+    {
336 336
         // phpcs:enable
337
-		global $conf;
338
-
339
-		return array(
340
-		'tasktime_rowid'=>$tasktime['rowid'],
341
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
342
-		'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
344
-		'tasktime_note'=>$tasktime['note'],
345
-		'tasktime_fk_user'=>$tasktime['fk_user'],
346
-		'tasktime_user_name'=>$tasktime['name'],
347
-		'tasktime_user_first'=>$tasktime['firstname'],
348
-		'tasktime_fullcivname'=>$tasktime['fullcivname'],
349
-		'tasktime_amountht'=>$tasktime['amountht'],
350
-		'tasktime_amountttc'=>$tasktime['amountttc'],
351
-		'tasktime_thm'=>$tasktime['thm'],
352
-		);
353
-	}
337
+        global $conf;
338
+
339
+        return array(
340
+        'tasktime_rowid'=>$tasktime['rowid'],
341
+        'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
342
+        'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343
+        'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
344
+        'tasktime_note'=>$tasktime['note'],
345
+        'tasktime_fk_user'=>$tasktime['fk_user'],
346
+        'tasktime_user_name'=>$tasktime['name'],
347
+        'tasktime_user_first'=>$tasktime['firstname'],
348
+        'tasktime_fullcivname'=>$tasktime['fullcivname'],
349
+        'tasktime_amountht'=>$tasktime['amountht'],
350
+        'tasktime_amountttc'=>$tasktime['amountttc'],
351
+        'tasktime_thm'=>$tasktime['thm'],
352
+        );
353
+    }
354 354
 
355 355
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
356
-	/**
357
-	 *	Define array with couple substitution key => substitution value
358
-	 *
359
-	 *	@param  array			$file				file array
360
-	 *	@param  Translate		$outputlangs        Lang object to use for output
361
-	 *  @return	array								Return a substitution array
362
-	 */
363
-	function get_substitutionarray_task_file($file,$outputlangs)
364
-	{
356
+    /**
357
+     *	Define array with couple substitution key => substitution value
358
+     *
359
+     *	@param  array			$file				file array
360
+     *	@param  Translate		$outputlangs        Lang object to use for output
361
+     *  @return	array								Return a substitution array
362
+     */
363
+    function get_substitutionarray_task_file($file,$outputlangs)
364
+    {
365 365
         // phpcs:enable
366
-		global $conf;
367
-
368
-		return array(
369
-		'tasksfile_name'=>$file['name'],
370
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
371
-		'tasksfile_size'=>$file['size']
372
-		);
373
-	}
374
-
375
-
376
-	/**
377
-	 *	Return description of a module
378
-	 *
379
-	 *	@param	Translate	$langs      Lang object to use for output
380
-	 *	@return string       			Description
381
-	 */
382
-	function info($langs)
383
-	{
384
-		global $conf,$langs;
385
-
386
-		// Load translation files required by the page
366
+        global $conf;
367
+
368
+        return array(
369
+        'tasksfile_name'=>$file['name'],
370
+        'tasksfile_date'=>dol_print_date($file['date'],'day'),
371
+        'tasksfile_size'=>$file['size']
372
+        );
373
+    }
374
+
375
+
376
+    /**
377
+     *	Return description of a module
378
+     *
379
+     *	@param	Translate	$langs      Lang object to use for output
380
+     *	@return string       			Description
381
+     */
382
+    function info($langs)
383
+    {
384
+        global $conf,$langs;
385
+
386
+        // Load translation files required by the page
387 387
         $langs->loadLangs(array("companies","errors"));
388 388
 
389
-		$form = new Form($this->db);
390
-
391
-		$texte = $this->description.".<br>\n";
392
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
-		$texte.= '<table class="nobordernopadding" width="100%">';
397
-
398
-		// List of directories area
399
-		$texte.= '<tr><td>';
400
-		$texttitle=$langs->trans("ListOfDirectories");
401
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
-		$listoffiles=array();
403
-		foreach($listofdir as $key=>$tmpdir)
404
-		{
405
-			$tmpdir=trim($tmpdir);
406
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407
-			if (! $tmpdir) {
408
-				unset($listofdir[$key]); continue;
409
-			}
410
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411
-			else
412
-			{
413
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
415
-			}
416
-		}
417
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
418
-		// Add list of substitution keys
419
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
421
-
422
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
425
-		$texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
-		$texte.= '</textarea>';
427
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
-		$texte.= '<br></div></div>';
430
-
431
-		// Scan directories
432
-		$nbofiles=count($listoffiles);
433
-		if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434
-		{
435
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
436
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437
-			$texte.=$nbofiles;
438
-			//$texte.=$nbofiles?'</a>':'';
439
-			$texte.='</b>';
440
-		}
441
-
442
-		if ($nbofiles)
443
-		{
444
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
445
-   			foreach($listoffiles as $file)
446
-   			{
389
+        $form = new Form($this->db);
390
+
391
+        $texte = $this->description.".<br>\n";
392
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395
+        $texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
+        $texte.= '<table class="nobordernopadding" width="100%">';
397
+
398
+        // List of directories area
399
+        $texte.= '<tr><td>';
400
+        $texttitle=$langs->trans("ListOfDirectories");
401
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
+        $listoffiles=array();
403
+        foreach($listofdir as $key=>$tmpdir)
404
+        {
405
+            $tmpdir=trim($tmpdir);
406
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407
+            if (! $tmpdir) {
408
+                unset($listofdir[$key]); continue;
409
+            }
410
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411
+            else
412
+            {
413
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
415
+            }
416
+        }
417
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
418
+        // Add list of substitution keys
419
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
421
+
422
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
425
+        $texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
+        $texte.= '</textarea>';
427
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
+        $texte.= '<br></div></div>';
430
+
431
+        // Scan directories
432
+        $nbofiles=count($listoffiles);
433
+        if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434
+        {
435
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
436
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437
+            $texte.=$nbofiles;
438
+            //$texte.=$nbofiles?'</a>':'';
439
+            $texte.='</b>';
440
+        }
441
+
442
+        if ($nbofiles)
443
+        {
444
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
445
+                foreach($listoffiles as $file)
446
+                {
447 447
                 $texte.=$file['name'].'<br>';
448
-   			}
449
-   			$texte.='<div id="div_'.get_class($this).'">';
450
-		}
448
+                }
449
+                $texte.='<div id="div_'.get_class($this).'">';
450
+        }
451 451
 
452
-		$texte.= '</td>';
452
+        $texte.= '</td>';
453 453
 
454
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456
-		$texte.= '</td>';
457
-		$texte.= '</tr>';
454
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456
+        $texte.= '</td>';
457
+        $texte.= '</tr>';
458 458
 
459
-		$texte.= '</table>';
460
-		$texte.= '</form>';
459
+        $texte.= '</table>';
460
+        $texte.= '</form>';
461 461
 
462
-		return $texte;
463
-	}
462
+        return $texte;
463
+    }
464 464
 
465 465
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
466
-	/**
467
-	 *	Function to build a document on disk using the generic odt module.
468
-	 *
469
-	 *	@param	Project		$object					Object source to build document
470
-	 *	@param	Translate	$outputlangs			Lang output object
471
-	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
472
-	 *	@return	int         						1 if OK, <=0 if KO
473
-	 */
474
-	function write_file($object,$outputlangs,$srctemplatepath)
475
-	{
466
+    /**
467
+     *	Function to build a document on disk using the generic odt module.
468
+     *
469
+     *	@param	Project		$object					Object source to build document
470
+     *	@param	Translate	$outputlangs			Lang output object
471
+     * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
472
+     *	@return	int         						1 if OK, <=0 if KO
473
+     */
474
+    function write_file($object,$outputlangs,$srctemplatepath)
475
+    {
476 476
         // phpcs:enable
477
-		global $user,$langs,$conf,$mysoc,$hookmanager;
478
-
479
-		if (empty($srctemplatepath))
480
-		{
481
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
482
-			return -1;
483
-		}
484
-
485
-		// Add odtgeneration hook
486
-		if (! is_object($hookmanager))
487
-		{
488
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489
-			$hookmanager=new HookManager($this->db);
490
-		}
491
-		$hookmanager->initHooks(array('odtgeneration'));
492
-		global $action;
493
-
494
-		if (! is_object($outputlangs)) $outputlangs=$langs;
495
-		$sav_charset_output=$outputlangs->charset_output;
496
-		$outputlangs->charset_output='UTF-8';
497
-
498
-		// Load translation files required by the page
499
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
500
-
501
-		if ($conf->projet->dir_output)
502
-		{
503
-			// If $object is id instead of object
504
-			if (! is_object($object))
505
-			{
506
-				$id = $object;
507
-				$object = new Project($this->db);
508
-				$result=$object->fetch($id);
509
-				if ($result < 0)
510
-				{
511
-					dol_print_error($this->db,$object->error);
512
-					return -1;
513
-				}
514
-			}
515
-
516
-			$dir = $conf->projet->dir_output;
517
-			$objectref = dol_sanitizeFileName($object->ref);
518
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519
-			$file = $dir . "/" . $objectref . ".odt";
520
-
521
-			if (! file_exists($dir))
522
-			{
523
-				if (dol_mkdir($dir) < 0)
524
-				{
525
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526
-					return -1;
527
-				}
528
-			}
529
-
530
-			if (file_exists($dir))
531
-			{
532
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
533
-				$newfile=basename($srctemplatepath);
534
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537
-				$newfiletmp=$objectref.'_'.$newfiletmp;
538
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539
-				// Get extension (ods or odt)
540
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542
-				{
543
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
545
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546
-				}
547
-				else
548
-				{
549
-					$filename=$newfiletmp.'.'.$newfileformat;
550
-				}
551
-				$file=$dir.'/'.$filename;
552
-				//print "newdir=".$dir;
553
-				//print "newfile=".$newfile;
554
-				//print "file=".$file;
555
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
556
-
557
-				dol_mkdir($conf->projet->dir_temp);
558
-
559
-				// If PROJECTLEADER contact defined on project, we use it
560
-				$usecontact=false;
561
-				$arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
562
-				if (count($arrayidcontact) > 0)
563
-				{
564
-					$usecontact=true;
565
-					$result=$object->fetch_contact($arrayidcontact[0]);
566
-				}
567
-
568
-				// Recipient name
569
-				$contactobject=null;
570
-				if (! empty($usecontact))
571
-				{
572
-        			// if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573
-        			$contactobject = $object->contact;
574
-				}
575
-
576
-				$socobject=$object->thirdparty;
577
-
578
-				// Make substitution
579
-				$substitutionarray=array(
580
-				'__FROM_NAME__' => $this->emetteur->name,
581
-				'__FROM_EMAIL__' => $this->emetteur->email,
582
-				);
583
-				complete_substitutions_array($substitutionarray, $langs, $object);
584
-				// Call the ODTSubstitution hook
585
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587
-
588
-				// Open and load template
589
-				require_once ODTPHP_PATH.'odf.php';
590
-				try {
591
-					$odfHandler = new odf(
592
-						$srctemplatepath,
593
-						array(
594
-						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
595
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596
-						'DELIMITER_LEFT'  => '{',
597
-						'DELIMITER_RIGHT' => '}'
598
-						)
599
-					);
600
-				} catch (Exception $e) {
601
-					$this->error=$e->getMessage();
602
-					dol_syslog($e->getMessage(), LOG_INFO);
603
-					return -1;
604
-				}
605
-				// After construction $odfHandler->contentXml contains content and
606
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
607
-				// [!-- BEGIN lines --]*[!-- END lines --]
608
-				//print html_entity_decode($odfHandler->__toString());
609
-				//print exit;
610
-
611
-
612
-				// Define substitution array
613
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614
-				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
617
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619
-				$array_other=$this->get_substitutionarray_other($outputlangs);
620
-				// retrieve contact information for use in object as contact_xxx tags
621
-				$array_project_contact = array();
622
-				if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
623
-
624
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625
-				complete_substitutions_array($tmparray, $outputlangs, $object);
626
-
627
-				// Call the ODTSubstitution hook
628
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
630
-
631
-				foreach($tmparray as $key=>$value)
632
-				{
633
-					try {
634
-						if (preg_match('/logo$/',$key)) // Image
635
-						{
636
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
637
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638
-						}
639
-						else    // Text
640
-						{
641
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
642
-						}
643
-					}
644
-					catch (OdfException $e)
645
-					{
477
+        global $user,$langs,$conf,$mysoc,$hookmanager;
478
+
479
+        if (empty($srctemplatepath))
480
+        {
481
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
482
+            return -1;
483
+        }
484
+
485
+        // Add odtgeneration hook
486
+        if (! is_object($hookmanager))
487
+        {
488
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489
+            $hookmanager=new HookManager($this->db);
490
+        }
491
+        $hookmanager->initHooks(array('odtgeneration'));
492
+        global $action;
493
+
494
+        if (! is_object($outputlangs)) $outputlangs=$langs;
495
+        $sav_charset_output=$outputlangs->charset_output;
496
+        $outputlangs->charset_output='UTF-8';
497
+
498
+        // Load translation files required by the page
499
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
500
+
501
+        if ($conf->projet->dir_output)
502
+        {
503
+            // If $object is id instead of object
504
+            if (! is_object($object))
505
+            {
506
+                $id = $object;
507
+                $object = new Project($this->db);
508
+                $result=$object->fetch($id);
509
+                if ($result < 0)
510
+                {
511
+                    dol_print_error($this->db,$object->error);
512
+                    return -1;
513
+                }
514
+            }
515
+
516
+            $dir = $conf->projet->dir_output;
517
+            $objectref = dol_sanitizeFileName($object->ref);
518
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519
+            $file = $dir . "/" . $objectref . ".odt";
520
+
521
+            if (! file_exists($dir))
522
+            {
523
+                if (dol_mkdir($dir) < 0)
524
+                {
525
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526
+                    return -1;
527
+                }
528
+            }
529
+
530
+            if (file_exists($dir))
531
+            {
532
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
533
+                $newfile=basename($srctemplatepath);
534
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537
+                $newfiletmp=$objectref.'_'.$newfiletmp;
538
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539
+                // Get extension (ods or odt)
540
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542
+                {
543
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
545
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546
+                }
547
+                else
548
+                {
549
+                    $filename=$newfiletmp.'.'.$newfileformat;
550
+                }
551
+                $file=$dir.'/'.$filename;
552
+                //print "newdir=".$dir;
553
+                //print "newfile=".$newfile;
554
+                //print "file=".$file;
555
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
556
+
557
+                dol_mkdir($conf->projet->dir_temp);
558
+
559
+                // If PROJECTLEADER contact defined on project, we use it
560
+                $usecontact=false;
561
+                $arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
562
+                if (count($arrayidcontact) > 0)
563
+                {
564
+                    $usecontact=true;
565
+                    $result=$object->fetch_contact($arrayidcontact[0]);
566
+                }
567
+
568
+                // Recipient name
569
+                $contactobject=null;
570
+                if (! empty($usecontact))
571
+                {
572
+                    // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573
+                    $contactobject = $object->contact;
574
+                }
575
+
576
+                $socobject=$object->thirdparty;
577
+
578
+                // Make substitution
579
+                $substitutionarray=array(
580
+                '__FROM_NAME__' => $this->emetteur->name,
581
+                '__FROM_EMAIL__' => $this->emetteur->email,
582
+                );
583
+                complete_substitutions_array($substitutionarray, $langs, $object);
584
+                // Call the ODTSubstitution hook
585
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587
+
588
+                // Open and load template
589
+                require_once ODTPHP_PATH.'odf.php';
590
+                try {
591
+                    $odfHandler = new odf(
592
+                        $srctemplatepath,
593
+                        array(
594
+                        'PATH_TO_TMP'	  => $conf->projet->dir_temp,
595
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596
+                        'DELIMITER_LEFT'  => '{',
597
+                        'DELIMITER_RIGHT' => '}'
598
+                        )
599
+                    );
600
+                } catch (Exception $e) {
601
+                    $this->error=$e->getMessage();
602
+                    dol_syslog($e->getMessage(), LOG_INFO);
603
+                    return -1;
604
+                }
605
+                // After construction $odfHandler->contentXml contains content and
606
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
607
+                // [!-- BEGIN lines --]*[!-- END lines --]
608
+                //print html_entity_decode($odfHandler->__toString());
609
+                //print exit;
610
+
611
+
612
+                // Define substitution array
613
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614
+                $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615
+                $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
617
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619
+                $array_other=$this->get_substitutionarray_other($outputlangs);
620
+                // retrieve contact information for use in object as contact_xxx tags
621
+                $array_project_contact = array();
622
+                if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
623
+
624
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625
+                complete_substitutions_array($tmparray, $outputlangs, $object);
626
+
627
+                // Call the ODTSubstitution hook
628
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
630
+
631
+                foreach($tmparray as $key=>$value)
632
+                {
633
+                    try {
634
+                        if (preg_match('/logo$/',$key)) // Image
635
+                        {
636
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
637
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638
+                        }
639
+                        else    // Text
640
+                        {
641
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
642
+                        }
643
+                    }
644
+                    catch (OdfException $e)
645
+                    {
646 646
                         dol_syslog($e->getMessage(), LOG_INFO);
647
-					}
648
-				}
649
-
650
-				// Replace tags of lines for tasks
651
-				try
652
-				{
653
-					$listlines = $odfHandler->setSegment('tasks');
654
-
655
-					$taskstatic = new Task($this->db);
656
-
657
-					// Security check
658
-					$socid=0;
659
-					if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660
-
661
-					$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662
-
663
-
664
-					foreach ($tasksarray as $task)
665
-					{
666
-						$tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
667
-						//complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668
-						foreach($tmparray as $key => $val)
669
-						{
670
-							try
671
-							{
672
-								$listlines->setVars($key, $val, true, 'UTF-8');
673
-							}
674
-							catch(OdfException $e)
675
-							{
676
-								dol_syslog($e->getMessage(), LOG_INFO);
677
-							}
678
-							catch(SegmentException $e)
679
-							{
680
-								dol_syslog($e->getMessage(), LOG_INFO);
681
-							}
682
-						}
683
-
684
-						$taskobj=new Task($this->db);
685
-						$taskobj->fetch($task->id);
686
-
687
-						// Replace tags of lines for contacts task
688
-						$sourcearray=array('internal','external');
689
-						$contact_arrray=array();
690
-						foreach ($sourcearray as $source) {
691
-							$contact_temp=$taskobj->liste_contact(-1,$source);
692
-							if ((is_array($contact_temp) && count($contact_temp) > 0))
693
-							{
694
-								$contact_arrray=array_merge($contact_arrray,$contact_temp);
695
-							}
696
-						}
697
-						if ((is_array($contact_arrray) && count($contact_arrray) > 0))
698
-						{
699
-							$listlinestaskres = $listlines->__get('tasksressources');
700
-
701
-							foreach ($contact_arrray as $contact)
702
-							{
703
-								if ($contact['source']=='internal') {
704
-									$objectdetail=new User($this->db);
705
-									$objectdetail->fetch($contact['id']);
706
-									$contact['socname']=$mysoc->name;
707
-								} elseif ($contact['source']=='external') {
708
-									$objectdetail=new Contact($this->db);
709
-									$objectdetail->fetch($contact['id']);
710
-
711
-									$soc=new Societe($this->db);
712
-									$soc->fetch($contact['socid']);
713
-									$contact['socname']=$soc->name;
714
-								}
715
-								$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
716
-
717
-								$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
718
-
719
-								foreach($tmparray as $key => $val)
720
-								{
721
-									try
722
-									{
723
-										$listlinestaskres->setVars($key, $val, true, 'UTF-8');
724
-									}
725
-									catch(OdfException $e)
726
-									{
727
-										dol_syslog($e->getMessage(), LOG_INFO);
728
-									}
729
-									catch(SegmentException $e)
730
-									{
731
-										dol_syslog($e->getMessage(), LOG_INFO);
732
-									}
733
-								}
734
-								$listlinestaskres->merge();
735
-							}
736
-						}
737
-
738
-						//Time ressources
739
-						$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740
-						$sql.= ", u.lastname, u.firstname, t.thm";
741
-						$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742
-						$sql .= " , ".MAIN_DB_PREFIX."user as u";
743
-						$sql .= " WHERE t.fk_task =".$task->id;
744
-						$sql .= " AND t.fk_user = u.rowid";
745
-						$sql .= " ORDER BY t.task_date DESC";
746
-
747
-						$resql = $this->db->query($sql);
748
-						if ($resql)
749
-						{
750
-							$num = $this->db->num_rows($resql);
751
-							$i = 0;
752
-							$tasks = array();
753
-							$row=array();
754
-							$listlinestasktime = $listlines->__get('taskstimes');
755
-							if (empty($num)) {
756
-								$row['rowid']='';
757
-								$row['task_date']='';
758
-								$row['task_duration']='';
759
-								$row['$tasktime']='';
760
-								$row['note']='';
761
-								$row['fk_user']='';
762
-								$row['name']='';
763
-								$row['firstname']='';
764
-								$row['fullcivname']='';
765
-								$row['amountht']='';
766
-								$row['amountttc']='';
767
-								$row['thm']='';
768
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
769
-								foreach($tmparray as $key => $val)
770
-								{
771
-									try
772
-									{
773
-										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
774
-									}
775
-									catch(OdfException $e)
776
-									{
777
-										dol_syslog($e->getMessage(), LOG_INFO);
778
-									}
779
-									catch(SegmentException $e)
780
-									{
781
-										dol_syslog($e->getMessage(), LOG_INFO);
782
-									}
783
-								}
784
-								$listlinestasktime->merge();
785
-							}
786
-							while ($i < $num)
787
-							{
788
-								$row = $this->db->fetch_array($resql);
789
-								if (!empty($row['fk_user'])) {
790
-									$objectdetail=new User($this->db);
791
-									$objectdetail->fetch($row['fk_user']);
792
-									$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
793
-								} else {
794
-									$row['fullcivname']='';
795
-								}
796
-
797
-								if (!empty($row['thm'])) {
798
-									$row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
799
-									$defaultvat = get_default_tva($mysoc, $mysoc);
800
-									$row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
801
-								} else {
802
-									$row['amountht']=0;
803
-									$row['amountttc']=0;
804
-									$row['thm']=0;
805
-								}
806
-
807
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
808
-
809
-								foreach($tmparray as $key => $val)
810
-								{
811
-									try
812
-									{
813
-										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
814
-									}
815
-									catch(OdfException $e)
816
-									{
817
-										dol_syslog($e->getMessage(), LOG_INFO);
818
-									}
819
-									catch(SegmentException $e)
820
-									{
821
-										dol_syslog($e->getMessage(), LOG_INFO);
822
-									}
823
-								}
824
-								$listlinestasktime->merge();
825
-								$i++;
826
-							}
827
-							$this->db->free($resql);
828
-						}
829
-
830
-
831
-						// Replace tags of project files
832
-						$listtasksfiles = $listlines->__get('tasksfiles');
833
-
834
-						$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
835
-						$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
836
-
837
-
838
-						foreach ($filearray as $filedetail)
839
-						{
840
-							$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
841
-							//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
842
-							foreach($tmparray as $key => $val)
843
-							{
844
-								try
845
-								{
846
-									$listtasksfiles->setVars($key, $val, true, 'UTF-8');
847
-								}
848
-								catch (OdfException $e)
849
-								{
850
-									dol_syslog($e->getMessage(), LOG_INFO);
851
-								}
852
-								catch (SegmentException $e)
853
-								{
854
-									dol_syslog($e->getMessage(), LOG_INFO);
855
-								}
856
-							}
857
-							$listtasksfiles->merge();
858
-						}
859
-						$listlines->merge();
860
-					}
861
-					$odfHandler->mergeSegment($listlines);
862
-				}
863
-				catch(OdfException $e)
864
-				{
865
-					$ExceptionTrace=$e->getTrace();
866
-					// no segment defined on ODT is not an error
867
-					if($ExceptionTrace[0]['function'] != 'setSegment')
868
-					{
869
-						$this->error=$e->getMessage();
870
-						dol_syslog($this->error, LOG_WARNING);
871
-						return -1;
872
-					}
873
-				}
874
-
875
-				// Replace tags of project files
876
-				try
877
-				{
878
-					$listlines = $odfHandler->setSegment('projectfiles');
879
-
880
-					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
881
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
882
-
883
-					foreach ($filearray as $filedetail)
884
-					{
885
-						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
886
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
887
-
888
-						foreach($tmparray as $key => $val)
889
-						{
890
-							try
891
-							{
892
-								$listlines->setVars($key, $val, true, 'UTF-8');
893
-							}
894
-							catch(OdfException $e)
895
-							{
896
-								dol_syslog($e->getMessage(), LOG_INFO);
897
-							}
898
-							catch(SegmentException $e)
899
-							{
900
-								dol_syslog($e->getMessage(), LOG_INFO);
901
-							}
902
-						}
903
-						$listlines->merge();
904
-					}
905
-					$odfHandler->mergeSegment($listlines);
906
-				}
907
-				catch(OdfException $e)
908
-				{
909
-					$this->error=$e->getMessage();
910
-					dol_syslog($this->error, LOG_WARNING);
911
-					return -1;
912
-				}
913
-
914
-				// Replace tags of lines for contacts
915
-				$sourcearray=array('internal','external');
916
-				$contact_arrray=array();
917
-				foreach ($sourcearray as $source) {
918
-					$contact_temp=$object->liste_contact(-1,$source);
919
-					if ((is_array($contact_temp) && count($contact_temp) > 0))
920
-					{
921
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
922
-					}
923
-				}
924
-				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
925
-				{
926
-					try
927
-					{
928
-						$listlines = $odfHandler->setSegment('projectcontacts');
929
-
930
-						foreach ($contact_arrray as $contact)
931
-						{
932
-							if ($contact['source']=='internal') {
933
-								$objectdetail=new User($this->db);
934
-								$objectdetail->fetch($contact['id']);
935
-								$contact['socname']=$mysoc->name;
936
-							} elseif ($contact['source']=='external') {
937
-								$objectdetail=new Contact($this->db);
938
-								$objectdetail->fetch($contact['id']);
939
-
940
-								$soc=new Societe($this->db);
941
-								$soc->fetch($contact['socid']);
942
-								$contact['socname']=$soc->name;
943
-							}
944
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
945
-
946
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
947
-							foreach($tmparray as $key => $val)
948
-							{
949
-								try
950
-								{
951
-									$listlines->setVars($key, $val, true, 'UTF-8');
952
-								}
953
-								catch(OdfException $e)
954
-								{
955
-									dol_syslog($e->getMessage(), LOG_INFO);
956
-								}
957
-								catch(SegmentException $e)
958
-								{
959
-									dol_syslog($e->getMessage(), LOG_INFO);
960
-								}
961
-							}
962
-							$listlines->merge();
963
-						}
964
-						$odfHandler->mergeSegment($listlines);
965
-					}
966
-					catch(OdfException $e)
967
-					{
968
-						$this->error=$e->getMessage();
969
-						dol_syslog($this->error, LOG_WARNING);
970
-						return -1;
971
-					}
972
-				}
973
-
974
-				//List of referent
975
-
976
-				$listofreferent = array(
977
-					'propal' => array(
978
-						'title' => "ListProposalsAssociatedProject",
979
-						'class' => 'Propal',
980
-						'table' => 'propal',
981
-						'test' => $conf->propal->enabled && $user->rights->propale->lire
982
-					),
983
-					'order' => array(
984
-						'title' => "ListOrdersAssociatedProject",
985
-						'class' => 'Commande',
986
-						'table' => 'commande',
987
-						'test' => $conf->commande->enabled && $user->rights->commande->lire
988
-					),
989
-					'invoice' => array(
990
-						'title' => "ListInvoicesAssociatedProject",
991
-						'class' => 'Facture',
992
-						'table' => 'facture',
993
-						'test' => $conf->facture->enabled && $user->rights->facture->lire
994
-					),
995
-					'invoice_predefined' => array(
996
-						'title' => "ListPredefinedInvoicesAssociatedProject",
997
-						'class' => 'FactureRec',
998
-						'table' => 'facture_rec',
999
-						'test' => $conf->facture->enabled && $user->rights->facture->lire
1000
-					),
1001
-					'proposal_supplier' => array(
1002
-						'title' => "ListSupplierProposalsAssociatedProject",
1003
-						'class' => 'SupplierProposal',
1004
-						'table' => 'supplier_proposal',
1005
-						'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
1006
-					),
1007
-					'order_supplier' => array(
1008
-						'title' => "ListSupplierOrdersAssociatedProject",
1009
-						'table' => 'commande_fournisseur',
1010
-						'class' => 'CommandeFournisseur',
1011
-						'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire
1012
-					),
1013
-					'invoice_supplier' => array(
1014
-						'title' => "ListSupplierInvoicesAssociatedProject",
1015
-						'table' => 'facture_fourn',
1016
-						'class' => 'FactureFournisseur',
1017
-						'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire
1018
-					),
1019
-					'contract' => array(
1020
-						'title' => "ListContractAssociatedProject",
1021
-						'class' => 'Contrat',
1022
-						'table' => 'contrat',
1023
-						'test' => $conf->contrat->enabled && $user->rights->contrat->lire
1024
-					),
1025
-					'intervention' => array(
1026
-						'title' => "ListFichinterAssociatedProject",
1027
-						'class' => 'Fichinter',
1028
-						'table' => 'fichinter',
1029
-						'disableamount' => 1,
1030
-						'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1031
-					),
1032
-					'shipping' => array(
1033
-						'title' => "ListShippingAssociatedProject",
1034
-						'class' => 'Expedition',
1035
-						'table' => 'expedition',
1036
-						'disableamount' => 1,
1037
-						'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1038
-					),
1039
-					'trip' => array(
1040
-						'title' => "ListTripAssociatedProject",
1041
-						'class' => 'Deplacement',
1042
-						'table' => 'deplacement',
1043
-						'disableamount' => 1,
1044
-						'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1045
-					),
1046
-					'expensereport' => array(
1047
-						'title' => "ListExpenseReportsAssociatedProject",
1048
-						'class' => 'ExpenseReportLine',
1049
-						'table' => 'expensereport_det',
1050
-						'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1051
-					),
1052
-					'donation' => array(
1053
-						'title' => "ListDonationsAssociatedProject",
1054
-						'class' => 'Don',
1055
-						'table' => 'don',
1056
-						'test' => $conf->don->enabled && $user->rights->don->lire
1057
-					),
1058
-					'loan' => array(
1059
-						'title' => "ListLoanAssociatedProject",
1060
-						'class' => 'Loan',
1061
-						'table' => 'loan',
1062
-						'test' => $conf->loan->enabled && $user->rights->loan->read
1063
-					),
1064
-					'chargesociales' => array(
1065
-						'title' => "ListSocialContributionAssociatedProject",
1066
-						'class' => 'ChargeSociales',
1067
-						'table' => 'chargesociales',
1068
-						'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id,
1069
-						'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1070
-					),
1071
-					'stock_mouvement' => array(
1072
-						'title' => "ListMouvementStockProject",
1073
-						'class' => 'MouvementStock',
1074
-						'table' => 'stock_mouvement',
1075
-						'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1076
-					),
1077
-					'agenda' => array(
1078
-						'title' => "ListActionsAssociatedProject",
1079
-						'class' => 'ActionComm',
1080
-						'table' => 'actioncomm',
1081
-						'disableamount' => 1,
1082
-						'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1083
-					),
1084
-				);
1085
-
1086
-				//Insert reference
1087
-				try
1088
-				{
1089
-					$listlines = $odfHandler->setSegment('projectrefs');
1090
-
1091
-					foreach ($listofreferent as $keyref => $valueref)
1092
-					{
1093
-						$title=$valueref['title'];
1094
-						$tablename=$valueref['table'];
1095
-						$classname=$valueref['class'];
1096
-						$qualified=$valueref['test'];
1097
-						if ($qualified)
1098
-						{
1099
-							$elementarray = $object->get_element_list($keyref, $tablename);
1100
-							if (count($elementarray)>0 && is_array($elementarray))
1101
-							{
1102
-								$total_ht = 0;
1103
-								$total_ttc = 0;
1104
-								$num=count($elementarray);
1105
-								for ($i = 0; $i < $num; $i++)
1106
-								{
1107
-									$ref_array=array();
1108
-									$ref_array['type']=$langs->trans($classname);
1109
-
1110
-									$element = new $classname($this->db);
1111
-									$element->fetch($elementarray[$i]);
1112
-									$element->fetch_thirdparty();
1113
-
1114
-									//Ref object
1115
-									$ref_array['ref']=$element->ref;
1116
-
1117
-									//Date object
1118
-									$dateref=$element->date;
1119
-									if (empty($dateref)) $dateref=$element->datep;
1120
-									if (empty($dateref)) $dateref=$element->date_contrat;
1121
-									$ref_array['date']=$dateref;
1122
-
1123
-									//Soc object
1124
-									if (is_object($element->thirdparty)) {
1125
-										$ref_array['socname']=$element->thirdparty->name;
1126
-									} else {
1127
-										$ref_array['socname']='';
1128
-									}
1129
-
1130
-									//Amount object
1131
-									if (empty($valueref['disableamount'])) {
1132
-										if (!empty($element->total_ht)) {
1133
-											$ref_array['amountht']=$element->total_ht;
1134
-											$ref_array['amountttc']=$element->total_ttc;
1135
-										} else {
1136
-											$ref_array['amountht']=0;
1137
-											$ref_array['amountttc']=0;
1138
-										}
1139
-									} else {
1140
-										$ref_array['amountht']='';
1141
-										$ref_array['amountttc']='';
1142
-									}
1143
-
1144
-									$ref_array['status']=$element->getLibStatut(0);
1145
-
1146
-									$tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1147
-
1148
-									foreach($tmparray as $key => $val)
1149
-									{
1150
-										try
1151
-										{
1152
-											$listlines->setVars($key, $val, true, 'UTF-8');
1153
-										}
1154
-										catch(OdfException $e)
1155
-										{
1156
-											dol_syslog($e->getMessage(), LOG_INFO);
1157
-										}
1158
-										catch(SegmentException $e)
1159
-										{
1160
-											dol_syslog($e->getMessage(), LOG_INFO);
1161
-										}
1162
-									}
1163
-									$listlines->merge();
1164
-								}
1165
-							}
1166
-						}
1167
-						$odfHandler->mergeSegment($listlines);
1168
-					}
1169
-				} catch(OdfException $e) {
1170
-					$this->error=$e->getMessage();
1171
-					dol_syslog($this->error, LOG_WARNING);
1172
-					return -1;
1173
-				}
1174
-
1175
-				// Replace labels translated
1176
-				$tmparray=$outputlangs->get_translations_for_substitutions();
1177
-				foreach($tmparray as $key=>$value)
1178
-				{
1179
-					try {
1180
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
1181
-					} catch (OdfException $e) {
647
+                    }
648
+                }
649
+
650
+                // Replace tags of lines for tasks
651
+                try
652
+                {
653
+                    $listlines = $odfHandler->setSegment('tasks');
654
+
655
+                    $taskstatic = new Task($this->db);
656
+
657
+                    // Security check
658
+                    $socid=0;
659
+                    if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660
+
661
+                    $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662
+
663
+
664
+                    foreach ($tasksarray as $task)
665
+                    {
666
+                        $tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
667
+                        //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668
+                        foreach($tmparray as $key => $val)
669
+                        {
670
+                            try
671
+                            {
672
+                                $listlines->setVars($key, $val, true, 'UTF-8');
673
+                            }
674
+                            catch(OdfException $e)
675
+                            {
676
+                                dol_syslog($e->getMessage(), LOG_INFO);
677
+                            }
678
+                            catch(SegmentException $e)
679
+                            {
680
+                                dol_syslog($e->getMessage(), LOG_INFO);
681
+                            }
682
+                        }
683
+
684
+                        $taskobj=new Task($this->db);
685
+                        $taskobj->fetch($task->id);
686
+
687
+                        // Replace tags of lines for contacts task
688
+                        $sourcearray=array('internal','external');
689
+                        $contact_arrray=array();
690
+                        foreach ($sourcearray as $source) {
691
+                            $contact_temp=$taskobj->liste_contact(-1,$source);
692
+                            if ((is_array($contact_temp) && count($contact_temp) > 0))
693
+                            {
694
+                                $contact_arrray=array_merge($contact_arrray,$contact_temp);
695
+                            }
696
+                        }
697
+                        if ((is_array($contact_arrray) && count($contact_arrray) > 0))
698
+                        {
699
+                            $listlinestaskres = $listlines->__get('tasksressources');
700
+
701
+                            foreach ($contact_arrray as $contact)
702
+                            {
703
+                                if ($contact['source']=='internal') {
704
+                                    $objectdetail=new User($this->db);
705
+                                    $objectdetail->fetch($contact['id']);
706
+                                    $contact['socname']=$mysoc->name;
707
+                                } elseif ($contact['source']=='external') {
708
+                                    $objectdetail=new Contact($this->db);
709
+                                    $objectdetail->fetch($contact['id']);
710
+
711
+                                    $soc=new Societe($this->db);
712
+                                    $soc->fetch($contact['socid']);
713
+                                    $contact['socname']=$soc->name;
714
+                                }
715
+                                $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
716
+
717
+                                $tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
718
+
719
+                                foreach($tmparray as $key => $val)
720
+                                {
721
+                                    try
722
+                                    {
723
+                                        $listlinestaskres->setVars($key, $val, true, 'UTF-8');
724
+                                    }
725
+                                    catch(OdfException $e)
726
+                                    {
727
+                                        dol_syslog($e->getMessage(), LOG_INFO);
728
+                                    }
729
+                                    catch(SegmentException $e)
730
+                                    {
731
+                                        dol_syslog($e->getMessage(), LOG_INFO);
732
+                                    }
733
+                                }
734
+                                $listlinestaskres->merge();
735
+                            }
736
+                        }
737
+
738
+                        //Time ressources
739
+                        $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740
+                        $sql.= ", u.lastname, u.firstname, t.thm";
741
+                        $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742
+                        $sql .= " , ".MAIN_DB_PREFIX."user as u";
743
+                        $sql .= " WHERE t.fk_task =".$task->id;
744
+                        $sql .= " AND t.fk_user = u.rowid";
745
+                        $sql .= " ORDER BY t.task_date DESC";
746
+
747
+                        $resql = $this->db->query($sql);
748
+                        if ($resql)
749
+                        {
750
+                            $num = $this->db->num_rows($resql);
751
+                            $i = 0;
752
+                            $tasks = array();
753
+                            $row=array();
754
+                            $listlinestasktime = $listlines->__get('taskstimes');
755
+                            if (empty($num)) {
756
+                                $row['rowid']='';
757
+                                $row['task_date']='';
758
+                                $row['task_duration']='';
759
+                                $row['$tasktime']='';
760
+                                $row['note']='';
761
+                                $row['fk_user']='';
762
+                                $row['name']='';
763
+                                $row['firstname']='';
764
+                                $row['fullcivname']='';
765
+                                $row['amountht']='';
766
+                                $row['amountttc']='';
767
+                                $row['thm']='';
768
+                                $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
769
+                                foreach($tmparray as $key => $val)
770
+                                {
771
+                                    try
772
+                                    {
773
+                                        $listlinestasktime->setVars($key, $val, true, 'UTF-8');
774
+                                    }
775
+                                    catch(OdfException $e)
776
+                                    {
777
+                                        dol_syslog($e->getMessage(), LOG_INFO);
778
+                                    }
779
+                                    catch(SegmentException $e)
780
+                                    {
781
+                                        dol_syslog($e->getMessage(), LOG_INFO);
782
+                                    }
783
+                                }
784
+                                $listlinestasktime->merge();
785
+                            }
786
+                            while ($i < $num)
787
+                            {
788
+                                $row = $this->db->fetch_array($resql);
789
+                                if (!empty($row['fk_user'])) {
790
+                                    $objectdetail=new User($this->db);
791
+                                    $objectdetail->fetch($row['fk_user']);
792
+                                    $row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
793
+                                } else {
794
+                                    $row['fullcivname']='';
795
+                                }
796
+
797
+                                if (!empty($row['thm'])) {
798
+                                    $row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
799
+                                    $defaultvat = get_default_tva($mysoc, $mysoc);
800
+                                    $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
801
+                                } else {
802
+                                    $row['amountht']=0;
803
+                                    $row['amountttc']=0;
804
+                                    $row['thm']=0;
805
+                                }
806
+
807
+                                $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
808
+
809
+                                foreach($tmparray as $key => $val)
810
+                                {
811
+                                    try
812
+                                    {
813
+                                        $listlinestasktime->setVars($key, $val, true, 'UTF-8');
814
+                                    }
815
+                                    catch(OdfException $e)
816
+                                    {
817
+                                        dol_syslog($e->getMessage(), LOG_INFO);
818
+                                    }
819
+                                    catch(SegmentException $e)
820
+                                    {
821
+                                        dol_syslog($e->getMessage(), LOG_INFO);
822
+                                    }
823
+                                }
824
+                                $listlinestasktime->merge();
825
+                                $i++;
826
+                            }
827
+                            $this->db->free($resql);
828
+                        }
829
+
830
+
831
+                        // Replace tags of project files
832
+                        $listtasksfiles = $listlines->__get('tasksfiles');
833
+
834
+                        $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
835
+                        $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
836
+
837
+
838
+                        foreach ($filearray as $filedetail)
839
+                        {
840
+                            $tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
841
+                            //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
842
+                            foreach($tmparray as $key => $val)
843
+                            {
844
+                                try
845
+                                {
846
+                                    $listtasksfiles->setVars($key, $val, true, 'UTF-8');
847
+                                }
848
+                                catch (OdfException $e)
849
+                                {
850
+                                    dol_syslog($e->getMessage(), LOG_INFO);
851
+                                }
852
+                                catch (SegmentException $e)
853
+                                {
854
+                                    dol_syslog($e->getMessage(), LOG_INFO);
855
+                                }
856
+                            }
857
+                            $listtasksfiles->merge();
858
+                        }
859
+                        $listlines->merge();
860
+                    }
861
+                    $odfHandler->mergeSegment($listlines);
862
+                }
863
+                catch(OdfException $e)
864
+                {
865
+                    $ExceptionTrace=$e->getTrace();
866
+                    // no segment defined on ODT is not an error
867
+                    if($ExceptionTrace[0]['function'] != 'setSegment')
868
+                    {
869
+                        $this->error=$e->getMessage();
870
+                        dol_syslog($this->error, LOG_WARNING);
871
+                        return -1;
872
+                    }
873
+                }
874
+
875
+                // Replace tags of project files
876
+                try
877
+                {
878
+                    $listlines = $odfHandler->setSegment('projectfiles');
879
+
880
+                    $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
881
+                    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
882
+
883
+                    foreach ($filearray as $filedetail)
884
+                    {
885
+                        //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
886
+                        $tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
887
+
888
+                        foreach($tmparray as $key => $val)
889
+                        {
890
+                            try
891
+                            {
892
+                                $listlines->setVars($key, $val, true, 'UTF-8');
893
+                            }
894
+                            catch(OdfException $e)
895
+                            {
896
+                                dol_syslog($e->getMessage(), LOG_INFO);
897
+                            }
898
+                            catch(SegmentException $e)
899
+                            {
900
+                                dol_syslog($e->getMessage(), LOG_INFO);
901
+                            }
902
+                        }
903
+                        $listlines->merge();
904
+                    }
905
+                    $odfHandler->mergeSegment($listlines);
906
+                }
907
+                catch(OdfException $e)
908
+                {
909
+                    $this->error=$e->getMessage();
910
+                    dol_syslog($this->error, LOG_WARNING);
911
+                    return -1;
912
+                }
913
+
914
+                // Replace tags of lines for contacts
915
+                $sourcearray=array('internal','external');
916
+                $contact_arrray=array();
917
+                foreach ($sourcearray as $source) {
918
+                    $contact_temp=$object->liste_contact(-1,$source);
919
+                    if ((is_array($contact_temp) && count($contact_temp) > 0))
920
+                    {
921
+                        $contact_arrray=array_merge($contact_arrray,$contact_temp);
922
+                    }
923
+                }
924
+                if ((is_array($contact_arrray) && count($contact_arrray) > 0))
925
+                {
926
+                    try
927
+                    {
928
+                        $listlines = $odfHandler->setSegment('projectcontacts');
929
+
930
+                        foreach ($contact_arrray as $contact)
931
+                        {
932
+                            if ($contact['source']=='internal') {
933
+                                $objectdetail=new User($this->db);
934
+                                $objectdetail->fetch($contact['id']);
935
+                                $contact['socname']=$mysoc->name;
936
+                            } elseif ($contact['source']=='external') {
937
+                                $objectdetail=new Contact($this->db);
938
+                                $objectdetail->fetch($contact['id']);
939
+
940
+                                $soc=new Societe($this->db);
941
+                                $soc->fetch($contact['socid']);
942
+                                $contact['socname']=$soc->name;
943
+                            }
944
+                            $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
945
+
946
+                            $tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
947
+                            foreach($tmparray as $key => $val)
948
+                            {
949
+                                try
950
+                                {
951
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
952
+                                }
953
+                                catch(OdfException $e)
954
+                                {
955
+                                    dol_syslog($e->getMessage(), LOG_INFO);
956
+                                }
957
+                                catch(SegmentException $e)
958
+                                {
959
+                                    dol_syslog($e->getMessage(), LOG_INFO);
960
+                                }
961
+                            }
962
+                            $listlines->merge();
963
+                        }
964
+                        $odfHandler->mergeSegment($listlines);
965
+                    }
966
+                    catch(OdfException $e)
967
+                    {
968
+                        $this->error=$e->getMessage();
969
+                        dol_syslog($this->error, LOG_WARNING);
970
+                        return -1;
971
+                    }
972
+                }
973
+
974
+                //List of referent
975
+
976
+                $listofreferent = array(
977
+                    'propal' => array(
978
+                        'title' => "ListProposalsAssociatedProject",
979
+                        'class' => 'Propal',
980
+                        'table' => 'propal',
981
+                        'test' => $conf->propal->enabled && $user->rights->propale->lire
982
+                    ),
983
+                    'order' => array(
984
+                        'title' => "ListOrdersAssociatedProject",
985
+                        'class' => 'Commande',
986
+                        'table' => 'commande',
987
+                        'test' => $conf->commande->enabled && $user->rights->commande->lire
988
+                    ),
989
+                    'invoice' => array(
990
+                        'title' => "ListInvoicesAssociatedProject",
991
+                        'class' => 'Facture',
992
+                        'table' => 'facture',
993
+                        'test' => $conf->facture->enabled && $user->rights->facture->lire
994
+                    ),
995
+                    'invoice_predefined' => array(
996
+                        'title' => "ListPredefinedInvoicesAssociatedProject",
997
+                        'class' => 'FactureRec',
998
+                        'table' => 'facture_rec',
999
+                        'test' => $conf->facture->enabled && $user->rights->facture->lire
1000
+                    ),
1001
+                    'proposal_supplier' => array(
1002
+                        'title' => "ListSupplierProposalsAssociatedProject",
1003
+                        'class' => 'SupplierProposal',
1004
+                        'table' => 'supplier_proposal',
1005
+                        'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
1006
+                    ),
1007
+                    'order_supplier' => array(
1008
+                        'title' => "ListSupplierOrdersAssociatedProject",
1009
+                        'table' => 'commande_fournisseur',
1010
+                        'class' => 'CommandeFournisseur',
1011
+                        'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire
1012
+                    ),
1013
+                    'invoice_supplier' => array(
1014
+                        'title' => "ListSupplierInvoicesAssociatedProject",
1015
+                        'table' => 'facture_fourn',
1016
+                        'class' => 'FactureFournisseur',
1017
+                        'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire
1018
+                    ),
1019
+                    'contract' => array(
1020
+                        'title' => "ListContractAssociatedProject",
1021
+                        'class' => 'Contrat',
1022
+                        'table' => 'contrat',
1023
+                        'test' => $conf->contrat->enabled && $user->rights->contrat->lire
1024
+                    ),
1025
+                    'intervention' => array(
1026
+                        'title' => "ListFichinterAssociatedProject",
1027
+                        'class' => 'Fichinter',
1028
+                        'table' => 'fichinter',
1029
+                        'disableamount' => 1,
1030
+                        'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1031
+                    ),
1032
+                    'shipping' => array(
1033
+                        'title' => "ListShippingAssociatedProject",
1034
+                        'class' => 'Expedition',
1035
+                        'table' => 'expedition',
1036
+                        'disableamount' => 1,
1037
+                        'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1038
+                    ),
1039
+                    'trip' => array(
1040
+                        'title' => "ListTripAssociatedProject",
1041
+                        'class' => 'Deplacement',
1042
+                        'table' => 'deplacement',
1043
+                        'disableamount' => 1,
1044
+                        'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1045
+                    ),
1046
+                    'expensereport' => array(
1047
+                        'title' => "ListExpenseReportsAssociatedProject",
1048
+                        'class' => 'ExpenseReportLine',
1049
+                        'table' => 'expensereport_det',
1050
+                        'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1051
+                    ),
1052
+                    'donation' => array(
1053
+                        'title' => "ListDonationsAssociatedProject",
1054
+                        'class' => 'Don',
1055
+                        'table' => 'don',
1056
+                        'test' => $conf->don->enabled && $user->rights->don->lire
1057
+                    ),
1058
+                    'loan' => array(
1059
+                        'title' => "ListLoanAssociatedProject",
1060
+                        'class' => 'Loan',
1061
+                        'table' => 'loan',
1062
+                        'test' => $conf->loan->enabled && $user->rights->loan->read
1063
+                    ),
1064
+                    'chargesociales' => array(
1065
+                        'title' => "ListSocialContributionAssociatedProject",
1066
+                        'class' => 'ChargeSociales',
1067
+                        'table' => 'chargesociales',
1068
+                        'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id,
1069
+                        'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1070
+                    ),
1071
+                    'stock_mouvement' => array(
1072
+                        'title' => "ListMouvementStockProject",
1073
+                        'class' => 'MouvementStock',
1074
+                        'table' => 'stock_mouvement',
1075
+                        'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1076
+                    ),
1077
+                    'agenda' => array(
1078
+                        'title' => "ListActionsAssociatedProject",
1079
+                        'class' => 'ActionComm',
1080
+                        'table' => 'actioncomm',
1081
+                        'disableamount' => 1,
1082
+                        'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1083
+                    ),
1084
+                );
1085
+
1086
+                //Insert reference
1087
+                try
1088
+                {
1089
+                    $listlines = $odfHandler->setSegment('projectrefs');
1090
+
1091
+                    foreach ($listofreferent as $keyref => $valueref)
1092
+                    {
1093
+                        $title=$valueref['title'];
1094
+                        $tablename=$valueref['table'];
1095
+                        $classname=$valueref['class'];
1096
+                        $qualified=$valueref['test'];
1097
+                        if ($qualified)
1098
+                        {
1099
+                            $elementarray = $object->get_element_list($keyref, $tablename);
1100
+                            if (count($elementarray)>0 && is_array($elementarray))
1101
+                            {
1102
+                                $total_ht = 0;
1103
+                                $total_ttc = 0;
1104
+                                $num=count($elementarray);
1105
+                                for ($i = 0; $i < $num; $i++)
1106
+                                {
1107
+                                    $ref_array=array();
1108
+                                    $ref_array['type']=$langs->trans($classname);
1109
+
1110
+                                    $element = new $classname($this->db);
1111
+                                    $element->fetch($elementarray[$i]);
1112
+                                    $element->fetch_thirdparty();
1113
+
1114
+                                    //Ref object
1115
+                                    $ref_array['ref']=$element->ref;
1116
+
1117
+                                    //Date object
1118
+                                    $dateref=$element->date;
1119
+                                    if (empty($dateref)) $dateref=$element->datep;
1120
+                                    if (empty($dateref)) $dateref=$element->date_contrat;
1121
+                                    $ref_array['date']=$dateref;
1122
+
1123
+                                    //Soc object
1124
+                                    if (is_object($element->thirdparty)) {
1125
+                                        $ref_array['socname']=$element->thirdparty->name;
1126
+                                    } else {
1127
+                                        $ref_array['socname']='';
1128
+                                    }
1129
+
1130
+                                    //Amount object
1131
+                                    if (empty($valueref['disableamount'])) {
1132
+                                        if (!empty($element->total_ht)) {
1133
+                                            $ref_array['amountht']=$element->total_ht;
1134
+                                            $ref_array['amountttc']=$element->total_ttc;
1135
+                                        } else {
1136
+                                            $ref_array['amountht']=0;
1137
+                                            $ref_array['amountttc']=0;
1138
+                                        }
1139
+                                    } else {
1140
+                                        $ref_array['amountht']='';
1141
+                                        $ref_array['amountttc']='';
1142
+                                    }
1143
+
1144
+                                    $ref_array['status']=$element->getLibStatut(0);
1145
+
1146
+                                    $tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1147
+
1148
+                                    foreach($tmparray as $key => $val)
1149
+                                    {
1150
+                                        try
1151
+                                        {
1152
+                                            $listlines->setVars($key, $val, true, 'UTF-8');
1153
+                                        }
1154
+                                        catch(OdfException $e)
1155
+                                        {
1156
+                                            dol_syslog($e->getMessage(), LOG_INFO);
1157
+                                        }
1158
+                                        catch(SegmentException $e)
1159
+                                        {
1160
+                                            dol_syslog($e->getMessage(), LOG_INFO);
1161
+                                        }
1162
+                                    }
1163
+                                    $listlines->merge();
1164
+                                }
1165
+                            }
1166
+                        }
1167
+                        $odfHandler->mergeSegment($listlines);
1168
+                    }
1169
+                } catch(OdfException $e) {
1170
+                    $this->error=$e->getMessage();
1171
+                    dol_syslog($this->error, LOG_WARNING);
1172
+                    return -1;
1173
+                }
1174
+
1175
+                // Replace labels translated
1176
+                $tmparray=$outputlangs->get_translations_for_substitutions();
1177
+                foreach($tmparray as $key=>$value)
1178
+                {
1179
+                    try {
1180
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
1181
+                    } catch (OdfException $e) {
1182 1182
                         dol_syslog($e->getMessage(), LOG_INFO);
1183
-					}
1184
-				}
1185
-
1186
-				// Call the beforeODTSave hook
1187
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1188
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1189
-
1190
-
1191
-				// Write new file
1192
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1193
-					try {
1194
-						$odfHandler->exportAsAttachedPDF($file);
1195
-					} catch (Exception $e) {
1196
-						$this->error=$e->getMessage();
1197
-						return -1;
1198
-					}
1199
-				} else {
1200
-					try {
1201
-						$odfHandler->saveToDisk($file);
1202
-					} catch (Exception $e){
1203
-						$this->error=$e->getMessage();
1183
+                    }
1184
+                }
1185
+
1186
+                // Call the beforeODTSave hook
1187
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1188
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1189
+
1190
+
1191
+                // Write new file
1192
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1193
+                    try {
1194
+                        $odfHandler->exportAsAttachedPDF($file);
1195
+                    } catch (Exception $e) {
1196
+                        $this->error=$e->getMessage();
1197
+                        return -1;
1198
+                    }
1199
+                } else {
1200
+                    try {
1201
+                        $odfHandler->saveToDisk($file);
1202
+                    } catch (Exception $e){
1203
+                        $this->error=$e->getMessage();
1204 1204
                         dol_syslog($e->getMessage(), LOG_INFO);
1205
-						return -1;
1206
-					}
1207
-				}
1208
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1210
-
1211
-				if (! empty($conf->global->MAIN_UMASK))
1212
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
1213
-
1214
-				$odfHandler=null;	// Destroy object
1215
-
1216
-				$this->result = array('fullpath'=>$file);
1217
-
1218
-				return 1;   // Success
1219
-			}
1220
-			else
1221
-			{
1222
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1223
-				return -1;
1224
-			}
1225
-		}
1226
-
1227
-		return -1;
1228
-	}
1205
+                        return -1;
1206
+                    }
1207
+                }
1208
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1210
+
1211
+                if (! empty($conf->global->MAIN_UMASK))
1212
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
1213
+
1214
+                $odfHandler=null;	// Destroy object
1215
+
1216
+                $this->result = array('fullpath'=>$file);
1217
+
1218
+                return 1;   // Success
1219
+            }
1220
+            else
1221
+            {
1222
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1223
+                return -1;
1224
+            }
1225
+        }
1226
+
1227
+        return -1;
1228
+    }
1229 1229
 }
Please login to merge, or discard this patch.
Spacing   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
40
+if (!empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43
+if (!empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46
+if (!empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47
+if (!empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48
+if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49
+if (!empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
50 50
 
51 51
 
52 52
 /**
@@ -88,32 +88,32 @@  discard block
 block discarded – undo
88 88
 		$this->db = $db;
89 89
 		$this->name = "ODT templates";
90 90
 		$this->description = $langs->trans("DocumentModelOdt");
91
-		$this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
91
+		$this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
92 92
 
93 93
 		// Dimension page pour format A4
94 94
 		$this->type = 'odt';
95 95
 		$this->page_largeur = 0;
96 96
 		$this->page_hauteur = 0;
97
-		$this->format = array($this->page_largeur,$this->page_hauteur);
98
-		$this->marge_gauche=0;
99
-		$this->marge_droite=0;
100
-		$this->marge_haute=0;
101
-		$this->marge_basse=0;
102
-
103
-		$this->option_logo = 1;                    // Affiche logo
104
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
105
-		$this->option_modereg = 0;                 // Affiche mode reglement
106
-		$this->option_condreg = 0;                 // Affiche conditions reglement
107
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
108
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
109
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
110
-		$this->option_credit_note = 0;             // Support credit notes
111
-		$this->option_freetext = 1;				   // Support add of a personalised text
112
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
+		$this->format = array($this->page_largeur, $this->page_hauteur);
98
+		$this->marge_gauche = 0;
99
+		$this->marge_droite = 0;
100
+		$this->marge_haute = 0;
101
+		$this->marge_basse = 0;
102
+
103
+		$this->option_logo = 1; // Affiche logo
104
+		$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
105
+		$this->option_modereg = 0; // Affiche mode reglement
106
+		$this->option_condreg = 0; // Affiche conditions reglement
107
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
108
+		$this->option_multilang = 1; // Dispo en plusieurs langues
109
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
110
+		$this->option_credit_note = 0; // Support credit notes
111
+		$this->option_freetext = 1; // Support add of a personalised text
112
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
113 113
 
114 114
 		// Recupere emetteur
115
-		$this->emetteur=$mysoc;
116
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
115
+		$this->emetteur = $mysoc;
116
+		if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
117 117
 	}
118 118
 
119 119
 
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
      * @param   string		    $array_key	        Name of the key for return array
127 127
 	 * @return	array								Array of substitution
128 128
 	 */
129
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
129
+	function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
130 130
 	{
131 131
         // phpcs:enable
132 132
 		global $conf;
133 133
 
134
-		$resarray=array(
134
+		$resarray = array(
135 135
 		    $array_key.'_id'=>$object->id,
136 136
             $array_key.'_ref'=>$object->ref,
137 137
             $array_key.'_title'=>$object->title,
138 138
             $array_key.'_description'=>$object->description,
139
-            $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
140
-            $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
141
-            $array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
142
-            $array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
139
+            $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'),
140
+            $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'),
141
+            $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'),
142
+            $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'),
143 143
             $array_key.'_note_private'=>$object->note_private,
144 144
             $array_key.'_note_public'=>$object->note_public,
145 145
             $array_key.'_public'=>$object->public,
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 
149 149
 		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150 150
 		$extrafields = new ExtraFields($this->db);
151
-		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
151
+		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true);
152 152
 		$object->fetch_optionals();
153 153
 
154
-		$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
154
+		$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
155 155
 
156 156
 		return $resarray;
157 157
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 *	@param  Translate		$outputlangs        Lang object to use for output
165 165
 	 *  @return	array								Return a substitution array
166 166
 	 */
167
-	function get_substitutionarray_tasks(Task $task,$outputlangs)
167
+	function get_substitutionarray_tasks(Task $task, $outputlangs)
168 168
 	{
169 169
         // phpcs:enable
170 170
 		global $conf;
@@ -178,21 +178,21 @@  discard block
 block discarded – undo
178 178
 			'task_description'=>$task->description,
179 179
 			'task_fk_parent'=>$task->fk_parent,
180 180
 			'task_duration'=>$task->duration,
181
-			'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
181
+			'task_duration_hour'=>convertSecondToTime($task->duration, 'all'),
182 182
 			'task_progress'=>$task->progress,
183 183
 			'task_public'=>$task->public,
184
-			'task_date_start'=>dol_print_date($task->date_start,'day'),
185
-			'task_date_end'=>dol_print_date($task->date_end,'day'),
184
+			'task_date_start'=>dol_print_date($task->date_start, 'day'),
185
+			'task_date_end'=>dol_print_date($task->date_end, 'day'),
186 186
 			'task_note_private'=>$task->note_private,
187 187
 			'task_note_public'=>$task->note_public
188 188
 		);
189 189
 
190 190
 		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191 191
 		$extrafields = new ExtraFields($this->db);
192
-		$extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193
-		$task->fetch_optionals($task->id,$extralabels);
192
+		$extralabels = $extrafields->fetch_name_optionals_label($task->table_element, true);
193
+		$task->fetch_optionals($task->id, $extralabels);
194 194
 
195
-		$resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
195
+		$resarray = $this->fill_substitutionarray_with_extrafields($task, $resarray, $extrafields, 'task', $outputlangs);
196 196
 
197 197
 		return $resarray;
198 198
 	}
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	 *	@param  Translate		$outputlangs        Lang object to use for output
206 206
 	 *  @return	array								Return a substitution array
207 207
 	 */
208
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
208
+	function get_substitutionarray_project_contacts($contact, $outputlangs)
209 209
 	{
210 210
         // phpcs:enable
211 211
 		global $conf;
212
-		$pc='projcontacts_'; // prefix to avoid typos
212
+		$pc = 'projcontacts_'; // prefix to avoid typos
213 213
 
214 214
 		$ret = array(
215 215
 			$pc.'id'=>$contact['id'],
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			$pc.'email'=>$contact['email']
224 224
 			);
225 225
 
226
-		if ($contact['source']=='external') {
226
+		if ($contact['source'] == 'external') {
227 227
 			$ret[$pc.'isInternal'] = ''; // not internal
228 228
 
229 229
 			$ct = new Contact($this->db);
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 
235 235
 			// fetch external user extrafields
236 236
 			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237
-			$extrafields=new ExtraFields($this->db);
238
-			$extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
237
+			$extrafields = new ExtraFields($this->db);
238
+			$extralabels = $extrafields->fetch_name_optionals_label($ct->table_element, true);
239 239
 			$extrafields_num = $ct->fetch_optionals();
240 240
 			//dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241
-			foreach($ct->array_options as $efkey => $efval) {
241
+			foreach ($ct->array_options as $efkey => $efval) {
242 242
 				dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243 243
 				$ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244 244
 			}
245
-		} elseif ($contact['source']=='internal') {
245
+		} elseif ($contact['source'] == 'internal') {
246 246
 			$ret[$pc.'isInternal'] = '1'; // this is an internal user
247 247
 
248 248
 			$ct = new User($this->db);
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
 	 *	@param  Translate		$outputlangs        Lang object to use for output
264 264
 	 *  @return	array								Return a substitution array
265 265
 	 */
266
-	function get_substitutionarray_project_file($file,$outputlangs)
266
+	function get_substitutionarray_project_file($file, $outputlangs)
267 267
 	{
268 268
         // phpcs:enable
269 269
 		global $conf;
270 270
 
271 271
 		return array(
272 272
 		'projfile_name'=>$file['name'],
273
-		'projfile_date'=>dol_print_date($file['date'],'day'),
273
+		'projfile_date'=>dol_print_date($file['date'], 'day'),
274 274
 		'projfile_size'=>$file['size']
275 275
 		);
276 276
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 *	@param  Translate		$outputlangs        Lang object to use for output
284 284
 	 *  @return	array								Return a substitution array
285 285
 	 */
286
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
286
+	function get_substitutionarray_project_reference($refdetail, $outputlangs)
287 287
 	{
288 288
         // phpcs:enable
289 289
 		global $conf;
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 		return array(
292 292
 		'projref_type'=>$refdetail['type'],
293 293
 		'projref_ref'=>$refdetail['ref'],
294
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
294
+		'projref_date'=>dol_print_date($refdetail['date'], 'day'),
295 295
 		'projref_socname'=>$refdetail['socname'],
296
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
296
+		'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs),
297
+		'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs),
298 298
 		'projref_status'=>$refdetail['status']
299 299
 		);
300 300
 	}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 *	@param  Translate		$outputlangs        Lang object to use for output
308 308
 	 *  @return	array								Return a substitution array
309 309
 	 */
310
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
310
+	function get_substitutionarray_tasksressource($taskressource, $outputlangs)
311 311
 	{
312 312
         // phpcs:enable
313 313
 		global $conf;
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *	@param  Translate		$outputlangs        Lang object to use for output
332 332
 	 *  @return	array								Return a substitution array
333 333
 	 */
334
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
334
+	function get_substitutionarray_taskstime($tasktime, $outputlangs)
335 335
 	{
336 336
         // phpcs:enable
337 337
 		global $conf;
338 338
 
339 339
 		return array(
340 340
 		'tasktime_rowid'=>$tasktime['rowid'],
341
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
341
+		'tasktime_task_date'=>dol_print_date($tasktime['task_date'], 'day'),
342 342
 		'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
343
+		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'], 'all'),
344 344
 		'tasktime_note'=>$tasktime['note'],
345 345
 		'tasktime_fk_user'=>$tasktime['fk_user'],
346 346
 		'tasktime_user_name'=>$tasktime['name'],
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 	 *	@param  Translate		$outputlangs        Lang object to use for output
361 361
 	 *  @return	array								Return a substitution array
362 362
 	 */
363
-	function get_substitutionarray_task_file($file,$outputlangs)
363
+	function get_substitutionarray_task_file($file, $outputlangs)
364 364
 	{
365 365
         // phpcs:enable
366 366
 		global $conf;
367 367
 
368 368
 		return array(
369 369
 		'tasksfile_name'=>$file['name'],
370
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
370
+		'tasksfile_date'=>dol_print_date($file['date'], 'day'),
371 371
 		'tasksfile_size'=>$file['size']
372 372
 		);
373 373
 	}
@@ -381,83 +381,83 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	function info($langs)
383 383
 	{
384
-		global $conf,$langs;
384
+		global $conf, $langs;
385 385
 
386 386
 		// Load translation files required by the page
387
-        $langs->loadLangs(array("companies","errors"));
387
+        $langs->loadLangs(array("companies", "errors"));
388 388
 
389 389
 		$form = new Form($this->db);
390 390
 
391 391
 		$texte = $this->description.".<br>\n";
392
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
-		$texte.= '<table class="nobordernopadding" width="100%">';
392
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
395
+		$texte .= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
+		$texte .= '<table class="nobordernopadding" width="100%">';
397 397
 
398 398
 		// List of directories area
399
-		$texte.= '<tr><td>';
400
-		$texttitle=$langs->trans("ListOfDirectories");
401
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
-		$listoffiles=array();
403
-		foreach($listofdir as $key=>$tmpdir)
399
+		$texte .= '<tr><td>';
400
+		$texttitle = $langs->trans("ListOfDirectories");
401
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
+		$listoffiles = array();
403
+		foreach ($listofdir as $key=>$tmpdir)
404 404
 		{
405
-			$tmpdir=trim($tmpdir);
406
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407
-			if (! $tmpdir) {
405
+			$tmpdir = trim($tmpdir);
406
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
407
+			if (!$tmpdir) {
408 408
 				unset($listofdir[$key]); continue;
409 409
 			}
410
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
410
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
411 411
 			else
412 412
 			{
413
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
413
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
414
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
415 415
 			}
416 416
 		}
417
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
417
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
418 418
 		// Add list of substitution keys
419
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
421
-
422
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
425
-		$texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
-		$texte.= '</textarea>';
427
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
-		$texte.= '<br></div></div>';
419
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
421
+
422
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
423
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
425
+		$texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
+		$texte .= '</textarea>';
427
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
428
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
+		$texte .= '<br></div></div>';
430 430
 
431 431
 		// Scan directories
432
-		$nbofiles=count($listoffiles);
433
-		if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
432
+		$nbofiles = count($listoffiles);
433
+		if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434 434
 		{
435
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
435
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
436 436
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437
-			$texte.=$nbofiles;
437
+			$texte .= $nbofiles;
438 438
 			//$texte.=$nbofiles?'</a>':'';
439
-			$texte.='</b>';
439
+			$texte .= '</b>';
440 440
 		}
441 441
 
442 442
 		if ($nbofiles)
443 443
 		{
444
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
445
-   			foreach($listoffiles as $file)
444
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
445
+   			foreach ($listoffiles as $file)
446 446
    			{
447
-                $texte.=$file['name'].'<br>';
447
+                $texte .= $file['name'].'<br>';
448 448
    			}
449
-   			$texte.='<div id="div_'.get_class($this).'">';
449
+   			$texte .= '<div id="div_'.get_class($this).'">';
450 450
 		}
451 451
 
452
-		$texte.= '</td>';
452
+		$texte .= '</td>';
453 453
 
454
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456
-		$texte.= '</td>';
457
-		$texte.= '</tr>';
454
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
456
+		$texte .= '</td>';
457
+		$texte .= '</tr>';
458 458
 
459
-		$texte.= '</table>';
460
-		$texte.= '</form>';
459
+		$texte .= '</table>';
460
+		$texte .= '</form>';
461 461
 
462 462
 		return $texte;
463 463
 	}
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
 	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
472 472
 	 *	@return	int         						1 if OK, <=0 if KO
473 473
 	 */
474
-	function write_file($object,$outputlangs,$srctemplatepath)
474
+	function write_file($object, $outputlangs, $srctemplatepath)
475 475
 	{
476 476
         // phpcs:enable
477
-		global $user,$langs,$conf,$mysoc,$hookmanager;
477
+		global $user, $langs, $conf, $mysoc, $hookmanager;
478 478
 
479 479
 		if (empty($srctemplatepath))
480 480
 		{
@@ -483,17 +483,17 @@  discard block
 block discarded – undo
483 483
 		}
484 484
 
485 485
 		// Add odtgeneration hook
486
-		if (! is_object($hookmanager))
486
+		if (!is_object($hookmanager))
487 487
 		{
488 488
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489
-			$hookmanager=new HookManager($this->db);
489
+			$hookmanager = new HookManager($this->db);
490 490
 		}
491 491
 		$hookmanager->initHooks(array('odtgeneration'));
492 492
 		global $action;
493 493
 
494
-		if (! is_object($outputlangs)) $outputlangs=$langs;
495
-		$sav_charset_output=$outputlangs->charset_output;
496
-		$outputlangs->charset_output='UTF-8';
494
+		if (!is_object($outputlangs)) $outputlangs = $langs;
495
+		$sav_charset_output = $outputlangs->charset_output;
496
+		$outputlangs->charset_output = 'UTF-8';
497 497
 
498 498
 		// Load translation files required by the page
499 499
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -501,28 +501,28 @@  discard block
 block discarded – undo
501 501
 		if ($conf->projet->dir_output)
502 502
 		{
503 503
 			// If $object is id instead of object
504
-			if (! is_object($object))
504
+			if (!is_object($object))
505 505
 			{
506 506
 				$id = $object;
507 507
 				$object = new Project($this->db);
508
-				$result=$object->fetch($id);
508
+				$result = $object->fetch($id);
509 509
 				if ($result < 0)
510 510
 				{
511
-					dol_print_error($this->db,$object->error);
511
+					dol_print_error($this->db, $object->error);
512 512
 					return -1;
513 513
 				}
514 514
 			}
515 515
 
516 516
 			$dir = $conf->projet->dir_output;
517 517
 			$objectref = dol_sanitizeFileName($object->ref);
518
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519
-			$file = $dir . "/" . $objectref . ".odt";
518
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
519
+			$file = $dir."/".$objectref.".odt";
520 520
 
521
-			if (! file_exists($dir))
521
+			if (!file_exists($dir))
522 522
 			{
523 523
 				if (dol_mkdir($dir) < 0)
524 524
 				{
525
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
525
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
526 526
 					return -1;
527 527
 				}
528 528
 			}
@@ -530,25 +530,25 @@  discard block
 block discarded – undo
530 530
 			if (file_exists($dir))
531 531
 			{
532 532
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
533
-				$newfile=basename($srctemplatepath);
534
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537
-				$newfiletmp=$objectref.'_'.$newfiletmp;
533
+				$newfile = basename($srctemplatepath);
534
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
535
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
536
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
537
+				$newfiletmp = $objectref.'_'.$newfiletmp;
538 538
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539 539
 				// Get extension (ods or odt)
540
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
540
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
541
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
542 542
 				{
543
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
545
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
543
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
544
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
545
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
546 546
 				}
547 547
 				else
548 548
 				{
549
-					$filename=$newfiletmp.'.'.$newfileformat;
549
+					$filename = $newfiletmp.'.'.$newfileformat;
550 550
 				}
551
-				$file=$dir.'/'.$filename;
551
+				$file = $dir.'/'.$filename;
552 552
 				//print "newdir=".$dir;
553 553
 				//print "newfile=".$newfile;
554 554
 				//print "file=".$file;
@@ -557,33 +557,33 @@  discard block
 block discarded – undo
557 557
 				dol_mkdir($conf->projet->dir_temp);
558 558
 
559 559
 				// If PROJECTLEADER contact defined on project, we use it
560
-				$usecontact=false;
561
-				$arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
560
+				$usecontact = false;
561
+				$arrayidcontact = $object->getIdContact('external', 'PROJECTLEADER');
562 562
 				if (count($arrayidcontact) > 0)
563 563
 				{
564
-					$usecontact=true;
565
-					$result=$object->fetch_contact($arrayidcontact[0]);
564
+					$usecontact = true;
565
+					$result = $object->fetch_contact($arrayidcontact[0]);
566 566
 				}
567 567
 
568 568
 				// Recipient name
569
-				$contactobject=null;
570
-				if (! empty($usecontact))
569
+				$contactobject = null;
570
+				if (!empty($usecontact))
571 571
 				{
572 572
         			// if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573 573
         			$contactobject = $object->contact;
574 574
 				}
575 575
 
576
-				$socobject=$object->thirdparty;
576
+				$socobject = $object->thirdparty;
577 577
 
578 578
 				// Make substitution
579
-				$substitutionarray=array(
579
+				$substitutionarray = array(
580 580
 				'__FROM_NAME__' => $this->emetteur->name,
581 581
 				'__FROM_EMAIL__' => $this->emetteur->email,
582 582
 				);
583 583
 				complete_substitutions_array($substitutionarray, $langs, $object);
584 584
 				// Call the ODTSubstitution hook
585
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
585
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
586
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
587 587
 
588 588
 				// Open and load template
589 589
 				require_once ODTPHP_PATH.'odf.php';
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 						$srctemplatepath,
593 593
 						array(
594 594
 						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
595
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
595
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596 596
 						'DELIMITER_LEFT'  => '{',
597 597
 						'DELIMITER_RIGHT' => '}'
598 598
 						)
599 599
 					);
600 600
 				} catch (Exception $e) {
601
-					$this->error=$e->getMessage();
601
+					$this->error = $e->getMessage();
602 602
 					dol_syslog($e->getMessage(), LOG_INFO);
603 603
 					return -1;
604 604
 				}
@@ -612,26 +612,26 @@  discard block
 block discarded – undo
612 612
 				// Define substitution array
613 613
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614 614
 				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
617
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619
-				$array_other=$this->get_substitutionarray_other($outputlangs);
615
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
616
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
617
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
618
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
619
+				$array_other = $this->get_substitutionarray_other($outputlangs);
620 620
 				// retrieve contact information for use in object as contact_xxx tags
621 621
 				$array_project_contact = array();
622
-				if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
622
+				if ($usecontact && is_object($contactobject)) $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
623 623
 
624
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
624
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
625 625
 				complete_substitutions_array($tmparray, $outputlangs, $object);
626 626
 
627 627
 				// Call the ODTSubstitution hook
628
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
628
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
629
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
630 630
 
631
-				foreach($tmparray as $key=>$value)
631
+				foreach ($tmparray as $key=>$value)
632 632
 				{
633 633
 					try {
634
-						if (preg_match('/logo$/',$key)) // Image
634
+						if (preg_match('/logo$/', $key)) // Image
635 635
 						{
636 636
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
637 637
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -655,43 +655,43 @@  discard block
 block discarded – undo
655 655
 					$taskstatic = new Task($this->db);
656 656
 
657 657
 					// Security check
658
-					$socid=0;
658
+					$socid = 0;
659 659
 					if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660 660
 
661
-					$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
661
+					$tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662 662
 
663 663
 
664 664
 					foreach ($tasksarray as $task)
665 665
 					{
666
-						$tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
666
+						$tmparray = $this->get_substitutionarray_tasks($task, $outputlangs);
667 667
 						//complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668
-						foreach($tmparray as $key => $val)
668
+						foreach ($tmparray as $key => $val)
669 669
 						{
670 670
 							try
671 671
 							{
672 672
 								$listlines->setVars($key, $val, true, 'UTF-8');
673 673
 							}
674
-							catch(OdfException $e)
674
+							catch (OdfException $e)
675 675
 							{
676 676
 								dol_syslog($e->getMessage(), LOG_INFO);
677 677
 							}
678
-							catch(SegmentException $e)
678
+							catch (SegmentException $e)
679 679
 							{
680 680
 								dol_syslog($e->getMessage(), LOG_INFO);
681 681
 							}
682 682
 						}
683 683
 
684
-						$taskobj=new Task($this->db);
684
+						$taskobj = new Task($this->db);
685 685
 						$taskobj->fetch($task->id);
686 686
 
687 687
 						// Replace tags of lines for contacts task
688
-						$sourcearray=array('internal','external');
689
-						$contact_arrray=array();
688
+						$sourcearray = array('internal', 'external');
689
+						$contact_arrray = array();
690 690
 						foreach ($sourcearray as $source) {
691
-							$contact_temp=$taskobj->liste_contact(-1,$source);
691
+							$contact_temp = $taskobj->liste_contact(-1, $source);
692 692
 							if ((is_array($contact_temp) && count($contact_temp) > 0))
693 693
 							{
694
-								$contact_arrray=array_merge($contact_arrray,$contact_temp);
694
+								$contact_arrray = array_merge($contact_arrray, $contact_temp);
695 695
 							}
696 696
 						}
697 697
 						if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -700,33 +700,33 @@  discard block
 block discarded – undo
700 700
 
701 701
 							foreach ($contact_arrray as $contact)
702 702
 							{
703
-								if ($contact['source']=='internal') {
704
-									$objectdetail=new User($this->db);
703
+								if ($contact['source'] == 'internal') {
704
+									$objectdetail = new User($this->db);
705 705
 									$objectdetail->fetch($contact['id']);
706
-									$contact['socname']=$mysoc->name;
707
-								} elseif ($contact['source']=='external') {
708
-									$objectdetail=new Contact($this->db);
706
+									$contact['socname'] = $mysoc->name;
707
+								} elseif ($contact['source'] == 'external') {
708
+									$objectdetail = new Contact($this->db);
709 709
 									$objectdetail->fetch($contact['id']);
710 710
 
711
-									$soc=new Societe($this->db);
711
+									$soc = new Societe($this->db);
712 712
 									$soc->fetch($contact['socid']);
713
-									$contact['socname']=$soc->name;
713
+									$contact['socname'] = $soc->name;
714 714
 								}
715
-								$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
715
+								$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
716 716
 
717
-								$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
717
+								$tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
718 718
 
719
-								foreach($tmparray as $key => $val)
719
+								foreach ($tmparray as $key => $val)
720 720
 								{
721 721
 									try
722 722
 									{
723 723
 										$listlinestaskres->setVars($key, $val, true, 'UTF-8');
724 724
 									}
725
-									catch(OdfException $e)
725
+									catch (OdfException $e)
726 726
 									{
727 727
 										dol_syslog($e->getMessage(), LOG_INFO);
728 728
 									}
729
-									catch(SegmentException $e)
729
+									catch (SegmentException $e)
730 730
 									{
731 731
 										dol_syslog($e->getMessage(), LOG_INFO);
732 732
 									}
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 
738 738
 						//Time ressources
739 739
 						$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740
-						$sql.= ", u.lastname, u.firstname, t.thm";
740
+						$sql .= ", u.lastname, u.firstname, t.thm";
741 741
 						$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742 742
 						$sql .= " , ".MAIN_DB_PREFIX."user as u";
743 743
 						$sql .= " WHERE t.fk_task =".$task->id;
@@ -750,33 +750,33 @@  discard block
 block discarded – undo
750 750
 							$num = $this->db->num_rows($resql);
751 751
 							$i = 0;
752 752
 							$tasks = array();
753
-							$row=array();
753
+							$row = array();
754 754
 							$listlinestasktime = $listlines->__get('taskstimes');
755 755
 							if (empty($num)) {
756
-								$row['rowid']='';
757
-								$row['task_date']='';
758
-								$row['task_duration']='';
759
-								$row['$tasktime']='';
760
-								$row['note']='';
761
-								$row['fk_user']='';
762
-								$row['name']='';
763
-								$row['firstname']='';
764
-								$row['fullcivname']='';
765
-								$row['amountht']='';
766
-								$row['amountttc']='';
767
-								$row['thm']='';
768
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
769
-								foreach($tmparray as $key => $val)
756
+								$row['rowid'] = '';
757
+								$row['task_date'] = '';
758
+								$row['task_duration'] = '';
759
+								$row['$tasktime'] = '';
760
+								$row['note'] = '';
761
+								$row['fk_user'] = '';
762
+								$row['name'] = '';
763
+								$row['firstname'] = '';
764
+								$row['fullcivname'] = '';
765
+								$row['amountht'] = '';
766
+								$row['amountttc'] = '';
767
+								$row['thm'] = '';
768
+								$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
769
+								foreach ($tmparray as $key => $val)
770 770
 								{
771 771
 									try
772 772
 									{
773 773
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
774 774
 									}
775
-									catch(OdfException $e)
775
+									catch (OdfException $e)
776 776
 									{
777 777
 										dol_syslog($e->getMessage(), LOG_INFO);
778 778
 									}
779
-									catch(SegmentException $e)
779
+									catch (SegmentException $e)
780 780
 									{
781 781
 										dol_syslog($e->getMessage(), LOG_INFO);
782 782
 									}
@@ -787,36 +787,36 @@  discard block
 block discarded – undo
787 787
 							{
788 788
 								$row = $this->db->fetch_array($resql);
789 789
 								if (!empty($row['fk_user'])) {
790
-									$objectdetail=new User($this->db);
790
+									$objectdetail = new User($this->db);
791 791
 									$objectdetail->fetch($row['fk_user']);
792
-									$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
792
+									$row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
793 793
 								} else {
794
-									$row['fullcivname']='';
794
+									$row['fullcivname'] = '';
795 795
 								}
796 796
 
797 797
 								if (!empty($row['thm'])) {
798
-									$row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
798
+									$row['amountht'] = ($row['task_duration'] / 3600) * $row['thm'];
799 799
 									$defaultvat = get_default_tva($mysoc, $mysoc);
800
-									$row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
800
+									$row['amountttc'] = price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT');
801 801
 								} else {
802
-									$row['amountht']=0;
803
-									$row['amountttc']=0;
804
-									$row['thm']=0;
802
+									$row['amountht'] = 0;
803
+									$row['amountttc'] = 0;
804
+									$row['thm'] = 0;
805 805
 								}
806 806
 
807
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
807
+								$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
808 808
 
809
-								foreach($tmparray as $key => $val)
809
+								foreach ($tmparray as $key => $val)
810 810
 								{
811 811
 									try
812 812
 									{
813 813
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
814 814
 									}
815
-									catch(OdfException $e)
815
+									catch (OdfException $e)
816 816
 									{
817 817
 										dol_syslog($e->getMessage(), LOG_INFO);
818 818
 									}
819
-									catch(SegmentException $e)
819
+									catch (SegmentException $e)
820 820
 									{
821 821
 										dol_syslog($e->getMessage(), LOG_INFO);
822 822
 									}
@@ -832,14 +832,14 @@  discard block
 block discarded – undo
832 832
 						$listtasksfiles = $listlines->__get('tasksfiles');
833 833
 
834 834
 						$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
835
-						$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
835
+						$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
836 836
 
837 837
 
838 838
 						foreach ($filearray as $filedetail)
839 839
 						{
840
-							$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
840
+							$tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
841 841
 							//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
842
-							foreach($tmparray as $key => $val)
842
+							foreach ($tmparray as $key => $val)
843 843
 							{
844 844
 								try
845 845
 								{
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 					}
861 861
 					$odfHandler->mergeSegment($listlines);
862 862
 				}
863
-				catch(OdfException $e)
863
+				catch (OdfException $e)
864 864
 				{
865
-					$ExceptionTrace=$e->getTrace();
865
+					$ExceptionTrace = $e->getTrace();
866 866
 					// no segment defined on ODT is not an error
867
-					if($ExceptionTrace[0]['function'] != 'setSegment')
867
+					if ($ExceptionTrace[0]['function'] != 'setSegment')
868 868
 					{
869
-						$this->error=$e->getMessage();
869
+						$this->error = $e->getMessage();
870 870
 						dol_syslog($this->error, LOG_WARNING);
871 871
 						return -1;
872 872
 					}
@@ -878,24 +878,24 @@  discard block
 block discarded – undo
878 878
 					$listlines = $odfHandler->setSegment('projectfiles');
879 879
 
880 880
 					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
881
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
881
+					$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
882 882
 
883 883
 					foreach ($filearray as $filedetail)
884 884
 					{
885 885
 						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
886
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
886
+						$tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
887 887
 
888
-						foreach($tmparray as $key => $val)
888
+						foreach ($tmparray as $key => $val)
889 889
 						{
890 890
 							try
891 891
 							{
892 892
 								$listlines->setVars($key, $val, true, 'UTF-8');
893 893
 							}
894
-							catch(OdfException $e)
894
+							catch (OdfException $e)
895 895
 							{
896 896
 								dol_syslog($e->getMessage(), LOG_INFO);
897 897
 							}
898
-							catch(SegmentException $e)
898
+							catch (SegmentException $e)
899 899
 							{
900 900
 								dol_syslog($e->getMessage(), LOG_INFO);
901 901
 							}
@@ -904,21 +904,21 @@  discard block
 block discarded – undo
904 904
 					}
905 905
 					$odfHandler->mergeSegment($listlines);
906 906
 				}
907
-				catch(OdfException $e)
907
+				catch (OdfException $e)
908 908
 				{
909
-					$this->error=$e->getMessage();
909
+					$this->error = $e->getMessage();
910 910
 					dol_syslog($this->error, LOG_WARNING);
911 911
 					return -1;
912 912
 				}
913 913
 
914 914
 				// Replace tags of lines for contacts
915
-				$sourcearray=array('internal','external');
916
-				$contact_arrray=array();
915
+				$sourcearray = array('internal', 'external');
916
+				$contact_arrray = array();
917 917
 				foreach ($sourcearray as $source) {
918
-					$contact_temp=$object->liste_contact(-1,$source);
918
+					$contact_temp = $object->liste_contact(-1, $source);
919 919
 					if ((is_array($contact_temp) && count($contact_temp) > 0))
920 920
 					{
921
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
921
+						$contact_arrray = array_merge($contact_arrray, $contact_temp);
922 922
 					}
923 923
 				}
924 924
 				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -929,32 +929,32 @@  discard block
 block discarded – undo
929 929
 
930 930
 						foreach ($contact_arrray as $contact)
931 931
 						{
932
-							if ($contact['source']=='internal') {
933
-								$objectdetail=new User($this->db);
932
+							if ($contact['source'] == 'internal') {
933
+								$objectdetail = new User($this->db);
934 934
 								$objectdetail->fetch($contact['id']);
935
-								$contact['socname']=$mysoc->name;
936
-							} elseif ($contact['source']=='external') {
937
-								$objectdetail=new Contact($this->db);
935
+								$contact['socname'] = $mysoc->name;
936
+							} elseif ($contact['source'] == 'external') {
937
+								$objectdetail = new Contact($this->db);
938 938
 								$objectdetail->fetch($contact['id']);
939 939
 
940
-								$soc=new Societe($this->db);
940
+								$soc = new Societe($this->db);
941 941
 								$soc->fetch($contact['socid']);
942
-								$contact['socname']=$soc->name;
942
+								$contact['socname'] = $soc->name;
943 943
 							}
944
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
944
+							$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
945 945
 
946
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
947
-							foreach($tmparray as $key => $val)
946
+							$tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
947
+							foreach ($tmparray as $key => $val)
948 948
 							{
949 949
 								try
950 950
 								{
951 951
 									$listlines->setVars($key, $val, true, 'UTF-8');
952 952
 								}
953
-								catch(OdfException $e)
953
+								catch (OdfException $e)
954 954
 								{
955 955
 									dol_syslog($e->getMessage(), LOG_INFO);
956 956
 								}
957
-								catch(SegmentException $e)
957
+								catch (SegmentException $e)
958 958
 								{
959 959
 									dol_syslog($e->getMessage(), LOG_INFO);
960 960
 								}
@@ -963,9 +963,9 @@  discard block
 block discarded – undo
963 963
 						}
964 964
 						$odfHandler->mergeSegment($listlines);
965 965
 					}
966
-					catch(OdfException $e)
966
+					catch (OdfException $e)
967 967
 					{
968
-						$this->error=$e->getMessage();
968
+						$this->error = $e->getMessage();
969 969
 						dol_syslog($this->error, LOG_WARNING);
970 970
 						return -1;
971 971
 					}
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 						'title' => "ListSocialContributionAssociatedProject",
1066 1066
 						'class' => 'ChargeSociales',
1067 1067
 						'table' => 'chargesociales',
1068
-						'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id,
1068
+						'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id,
1069 1069
 						'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1070 1070
 					),
1071 1071
 					'stock_mouvement' => array(
1072 1072
 						'title' => "ListMouvementStockProject",
1073 1073
 						'class' => 'MouvementStock',
1074 1074
 						'table' => 'stock_mouvement',
1075
-						'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1075
+						'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1076 1076
 					),
1077 1077
 					'agenda' => array(
1078 1078
 						'title' => "ListActionsAssociatedProject",
@@ -1090,72 +1090,72 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
 					foreach ($listofreferent as $keyref => $valueref)
1092 1092
 					{
1093
-						$title=$valueref['title'];
1094
-						$tablename=$valueref['table'];
1095
-						$classname=$valueref['class'];
1096
-						$qualified=$valueref['test'];
1093
+						$title = $valueref['title'];
1094
+						$tablename = $valueref['table'];
1095
+						$classname = $valueref['class'];
1096
+						$qualified = $valueref['test'];
1097 1097
 						if ($qualified)
1098 1098
 						{
1099 1099
 							$elementarray = $object->get_element_list($keyref, $tablename);
1100
-							if (count($elementarray)>0 && is_array($elementarray))
1100
+							if (count($elementarray) > 0 && is_array($elementarray))
1101 1101
 							{
1102 1102
 								$total_ht = 0;
1103 1103
 								$total_ttc = 0;
1104
-								$num=count($elementarray);
1104
+								$num = count($elementarray);
1105 1105
 								for ($i = 0; $i < $num; $i++)
1106 1106
 								{
1107
-									$ref_array=array();
1108
-									$ref_array['type']=$langs->trans($classname);
1107
+									$ref_array = array();
1108
+									$ref_array['type'] = $langs->trans($classname);
1109 1109
 
1110 1110
 									$element = new $classname($this->db);
1111 1111
 									$element->fetch($elementarray[$i]);
1112 1112
 									$element->fetch_thirdparty();
1113 1113
 
1114 1114
 									//Ref object
1115
-									$ref_array['ref']=$element->ref;
1115
+									$ref_array['ref'] = $element->ref;
1116 1116
 
1117 1117
 									//Date object
1118
-									$dateref=$element->date;
1119
-									if (empty($dateref)) $dateref=$element->datep;
1120
-									if (empty($dateref)) $dateref=$element->date_contrat;
1121
-									$ref_array['date']=$dateref;
1118
+									$dateref = $element->date;
1119
+									if (empty($dateref)) $dateref = $element->datep;
1120
+									if (empty($dateref)) $dateref = $element->date_contrat;
1121
+									$ref_array['date'] = $dateref;
1122 1122
 
1123 1123
 									//Soc object
1124 1124
 									if (is_object($element->thirdparty)) {
1125
-										$ref_array['socname']=$element->thirdparty->name;
1125
+										$ref_array['socname'] = $element->thirdparty->name;
1126 1126
 									} else {
1127
-										$ref_array['socname']='';
1127
+										$ref_array['socname'] = '';
1128 1128
 									}
1129 1129
 
1130 1130
 									//Amount object
1131 1131
 									if (empty($valueref['disableamount'])) {
1132 1132
 										if (!empty($element->total_ht)) {
1133
-											$ref_array['amountht']=$element->total_ht;
1134
-											$ref_array['amountttc']=$element->total_ttc;
1133
+											$ref_array['amountht'] = $element->total_ht;
1134
+											$ref_array['amountttc'] = $element->total_ttc;
1135 1135
 										} else {
1136
-											$ref_array['amountht']=0;
1137
-											$ref_array['amountttc']=0;
1136
+											$ref_array['amountht'] = 0;
1137
+											$ref_array['amountttc'] = 0;
1138 1138
 										}
1139 1139
 									} else {
1140
-										$ref_array['amountht']='';
1141
-										$ref_array['amountttc']='';
1140
+										$ref_array['amountht'] = '';
1141
+										$ref_array['amountttc'] = '';
1142 1142
 									}
1143 1143
 
1144
-									$ref_array['status']=$element->getLibStatut(0);
1144
+									$ref_array['status'] = $element->getLibStatut(0);
1145 1145
 
1146
-									$tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1146
+									$tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs);
1147 1147
 
1148
-									foreach($tmparray as $key => $val)
1148
+									foreach ($tmparray as $key => $val)
1149 1149
 									{
1150 1150
 										try
1151 1151
 										{
1152 1152
 											$listlines->setVars($key, $val, true, 'UTF-8');
1153 1153
 										}
1154
-										catch(OdfException $e)
1154
+										catch (OdfException $e)
1155 1155
 										{
1156 1156
 											dol_syslog($e->getMessage(), LOG_INFO);
1157 1157
 										}
1158
-										catch(SegmentException $e)
1158
+										catch (SegmentException $e)
1159 1159
 										{
1160 1160
 											dol_syslog($e->getMessage(), LOG_INFO);
1161 1161
 										}
@@ -1166,15 +1166,15 @@  discard block
 block discarded – undo
1166 1166
 						}
1167 1167
 						$odfHandler->mergeSegment($listlines);
1168 1168
 					}
1169
-				} catch(OdfException $e) {
1170
-					$this->error=$e->getMessage();
1169
+				} catch (OdfException $e) {
1170
+					$this->error = $e->getMessage();
1171 1171
 					dol_syslog($this->error, LOG_WARNING);
1172 1172
 					return -1;
1173 1173
 				}
1174 1174
 
1175 1175
 				// Replace labels translated
1176
-				$tmparray=$outputlangs->get_translations_for_substitutions();
1177
-				foreach($tmparray as $key=>$value)
1176
+				$tmparray = $outputlangs->get_translations_for_substitutions();
1177
+				foreach ($tmparray as $key=>$value)
1178 1178
 				{
1179 1179
 					try {
1180 1180
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
 				}
1185 1185
 
1186 1186
 				// Call the beforeODTSave hook
1187
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1188
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1187
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1188
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1189 1189
 
1190 1190
 
1191 1191
 				// Write new file
@@ -1193,33 +1193,33 @@  discard block
 block discarded – undo
1193 1193
 					try {
1194 1194
 						$odfHandler->exportAsAttachedPDF($file);
1195 1195
 					} catch (Exception $e) {
1196
-						$this->error=$e->getMessage();
1196
+						$this->error = $e->getMessage();
1197 1197
 						return -1;
1198 1198
 					}
1199 1199
 				} else {
1200 1200
 					try {
1201 1201
 						$odfHandler->saveToDisk($file);
1202
-					} catch (Exception $e){
1203
-						$this->error=$e->getMessage();
1202
+					} catch (Exception $e) {
1203
+						$this->error = $e->getMessage();
1204 1204
                         dol_syslog($e->getMessage(), LOG_INFO);
1205 1205
 						return -1;
1206 1206
 					}
1207 1207
 				}
1208
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1208
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1209
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1210 1210
 
1211
-				if (! empty($conf->global->MAIN_UMASK))
1211
+				if (!empty($conf->global->MAIN_UMASK))
1212 1212
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
1213 1213
 
1214
-				$odfHandler=null;	// Destroy object
1214
+				$odfHandler = null; // Destroy object
1215 1215
 
1216 1216
 				$this->result = array('fullpath'=>$file);
1217 1217
 
1218
-				return 1;   // Success
1218
+				return 1; // Success
1219 1219
 			}
1220 1220
 			else
1221 1221
 			{
1222
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1222
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
1223 1223
 				return -1;
1224 1224
 			}
1225 1225
 		}
Please login to merge, or discard this patch.
Braces   +92 added lines, -71 removed lines patch added patch discarded remove patch
@@ -37,16 +37,36 @@  discard block
 block discarded – undo
37 37
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
40
+if (! empty($conf->propal->enabled)) {
41
+    require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
+}
43
+if (! empty($conf->facture->enabled)) {
44
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
45
+}
46
+if (! empty($conf->facture->enabled)) {
47
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
48
+}
49
+if (! empty($conf->commande->enabled)) {
50
+    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
51
+}
52
+if (! empty($conf->fournisseur->enabled)) {
53
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
54
+}
55
+if (! empty($conf->fournisseur->enabled)) {
56
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
57
+}
58
+if (! empty($conf->contrat->enabled)) {
59
+    require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
60
+}
61
+if (! empty($conf->ficheinter->enabled)) {
62
+    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
63
+}
64
+if (! empty($conf->deplacement->enabled)) {
65
+    require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
66
+}
67
+if (! empty($conf->agenda->enabled)) {
68
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
69
+}
50 70
 
51 71
 
52 72
 /**
@@ -113,7 +133,10 @@  discard block
 block discarded – undo
113 133
 
114 134
 		// Recupere emetteur
115 135
 		$this->emetteur=$mysoc;
116
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
136
+		if (! $this->emetteur->pays_code) {
137
+		    $this->emetteur->pays_code=substr($langs->defaultlang,-2);
138
+		}
139
+		// Par defaut, si n'etait pas defini
117 140
 	}
118 141
 
119 142
 
@@ -407,11 +430,14 @@  discard block
 block discarded – undo
407 430
 			if (! $tmpdir) {
408 431
 				unset($listofdir[$key]); continue;
409 432
 			}
410
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411
-			else
433
+			if (! is_dir($tmpdir)) {
434
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
435
+			} else
412 436
 			{
413 437
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
438
+				if (count($tmpfiles)) {
439
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
440
+				}
415 441
 			}
416 442
 		}
417 443
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -491,7 +517,9 @@  discard block
 block discarded – undo
491 517
 		$hookmanager->initHooks(array('odtgeneration'));
492 518
 		global $action;
493 519
 
494
-		if (! is_object($outputlangs)) $outputlangs=$langs;
520
+		if (! is_object($outputlangs)) {
521
+		    $outputlangs=$langs;
522
+		}
495 523
 		$sav_charset_output=$outputlangs->charset_output;
496 524
 		$outputlangs->charset_output='UTF-8';
497 525
 
@@ -515,7 +543,9 @@  discard block
 block discarded – undo
515 543
 
516 544
 			$dir = $conf->projet->dir_output;
517 545
 			$objectref = dol_sanitizeFileName($object->ref);
518
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
546
+			if (! preg_match('/specimen/i',$objectref)) {
547
+			    $dir.= "/" . $objectref;
548
+			}
519 549
 			$file = $dir . "/" . $objectref . ".odt";
520 550
 
521 551
 			if (! file_exists($dir))
@@ -541,10 +571,11 @@  discard block
 block discarded – undo
541 571
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542 572
 				{
543 573
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
574
+				    if ($format == '1') {
575
+				        $format='%Y%m%d%H%M%S';
576
+				    }
545 577
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546
-				}
547
-				else
578
+				} else
548 579
 				{
549 580
 					$filename=$newfiletmp.'.'.$newfileformat;
550 581
 				}
@@ -619,7 +650,9 @@  discard block
 block discarded – undo
619 650
 				$array_other=$this->get_substitutionarray_other($outputlangs);
620 651
 				// retrieve contact information for use in object as contact_xxx tags
621 652
 				$array_project_contact = array();
622
-				if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
653
+				if ($usecontact && is_object($contactobject)) {
654
+				    $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
655
+				}
623 656
 
624 657
 				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625 658
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -631,17 +664,18 @@  discard block
 block discarded – undo
631 664
 				foreach($tmparray as $key=>$value)
632 665
 				{
633 666
 					try {
634
-						if (preg_match('/logo$/',$key)) // Image
667
+						if (preg_match('/logo$/',$key)) {
668
+						    // Image
635 669
 						{
636 670
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
637
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638
-						}
639
-						else    // Text
671
+						} else {
672
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
673
+							}
674
+						} else    // Text
640 675
 						{
641 676
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
642 677
 						}
643
-					}
644
-					catch (OdfException $e)
678
+					} catch (OdfException $e)
645 679
 					{
646 680
                         dol_syslog($e->getMessage(), LOG_INFO);
647 681
 					}
@@ -656,7 +690,9 @@  discard block
 block discarded – undo
656 690
 
657 691
 					// Security check
658 692
 					$socid=0;
659
-					if (!empty($object->fk_soc)) $socid = $object->fk_soc;
693
+					if (!empty($object->fk_soc)) {
694
+					    $socid = $object->fk_soc;
695
+					}
660 696
 
661 697
 					$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662 698
 
@@ -670,12 +706,10 @@  discard block
 block discarded – undo
670 706
 							try
671 707
 							{
672 708
 								$listlines->setVars($key, $val, true, 'UTF-8');
673
-							}
674
-							catch(OdfException $e)
709
+							} catch(OdfException $e)
675 710
 							{
676 711
 								dol_syslog($e->getMessage(), LOG_INFO);
677
-							}
678
-							catch(SegmentException $e)
712
+							} catch(SegmentException $e)
679 713
 							{
680 714
 								dol_syslog($e->getMessage(), LOG_INFO);
681 715
 							}
@@ -721,12 +755,10 @@  discard block
 block discarded – undo
721 755
 									try
722 756
 									{
723 757
 										$listlinestaskres->setVars($key, $val, true, 'UTF-8');
724
-									}
725
-									catch(OdfException $e)
758
+									} catch(OdfException $e)
726 759
 									{
727 760
 										dol_syslog($e->getMessage(), LOG_INFO);
728
-									}
729
-									catch(SegmentException $e)
761
+									} catch(SegmentException $e)
730 762
 									{
731 763
 										dol_syslog($e->getMessage(), LOG_INFO);
732 764
 									}
@@ -771,12 +803,10 @@  discard block
 block discarded – undo
771 803
 									try
772 804
 									{
773 805
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
774
-									}
775
-									catch(OdfException $e)
806
+									} catch(OdfException $e)
776 807
 									{
777 808
 										dol_syslog($e->getMessage(), LOG_INFO);
778
-									}
779
-									catch(SegmentException $e)
809
+									} catch(SegmentException $e)
780 810
 									{
781 811
 										dol_syslog($e->getMessage(), LOG_INFO);
782 812
 									}
@@ -811,12 +841,10 @@  discard block
 block discarded – undo
811 841
 									try
812 842
 									{
813 843
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
814
-									}
815
-									catch(OdfException $e)
844
+									} catch(OdfException $e)
816 845
 									{
817 846
 										dol_syslog($e->getMessage(), LOG_INFO);
818
-									}
819
-									catch(SegmentException $e)
847
+									} catch(SegmentException $e)
820 848
 									{
821 849
 										dol_syslog($e->getMessage(), LOG_INFO);
822 850
 									}
@@ -844,12 +872,10 @@  discard block
 block discarded – undo
844 872
 								try
845 873
 								{
846 874
 									$listtasksfiles->setVars($key, $val, true, 'UTF-8');
847
-								}
848
-								catch (OdfException $e)
875
+								} catch (OdfException $e)
849 876
 								{
850 877
 									dol_syslog($e->getMessage(), LOG_INFO);
851
-								}
852
-								catch (SegmentException $e)
878
+								} catch (SegmentException $e)
853 879
 								{
854 880
 									dol_syslog($e->getMessage(), LOG_INFO);
855 881
 								}
@@ -859,8 +885,7 @@  discard block
 block discarded – undo
859 885
 						$listlines->merge();
860 886
 					}
861 887
 					$odfHandler->mergeSegment($listlines);
862
-				}
863
-				catch(OdfException $e)
888
+				} catch(OdfException $e)
864 889
 				{
865 890
 					$ExceptionTrace=$e->getTrace();
866 891
 					// no segment defined on ODT is not an error
@@ -890,12 +915,10 @@  discard block
 block discarded – undo
890 915
 							try
891 916
 							{
892 917
 								$listlines->setVars($key, $val, true, 'UTF-8');
893
-							}
894
-							catch(OdfException $e)
918
+							} catch(OdfException $e)
895 919
 							{
896 920
 								dol_syslog($e->getMessage(), LOG_INFO);
897
-							}
898
-							catch(SegmentException $e)
921
+							} catch(SegmentException $e)
899 922
 							{
900 923
 								dol_syslog($e->getMessage(), LOG_INFO);
901 924
 							}
@@ -903,8 +926,7 @@  discard block
 block discarded – undo
903 926
 						$listlines->merge();
904 927
 					}
905 928
 					$odfHandler->mergeSegment($listlines);
906
-				}
907
-				catch(OdfException $e)
929
+				} catch(OdfException $e)
908 930
 				{
909 931
 					$this->error=$e->getMessage();
910 932
 					dol_syslog($this->error, LOG_WARNING);
@@ -949,12 +971,10 @@  discard block
 block discarded – undo
949 971
 								try
950 972
 								{
951 973
 									$listlines->setVars($key, $val, true, 'UTF-8');
952
-								}
953
-								catch(OdfException $e)
974
+								} catch(OdfException $e)
954 975
 								{
955 976
 									dol_syslog($e->getMessage(), LOG_INFO);
956
-								}
957
-								catch(SegmentException $e)
977
+								} catch(SegmentException $e)
958 978
 								{
959 979
 									dol_syslog($e->getMessage(), LOG_INFO);
960 980
 								}
@@ -962,8 +982,7 @@  discard block
 block discarded – undo
962 982
 							$listlines->merge();
963 983
 						}
964 984
 						$odfHandler->mergeSegment($listlines);
965
-					}
966
-					catch(OdfException $e)
985
+					} catch(OdfException $e)
967 986
 					{
968 987
 						$this->error=$e->getMessage();
969 988
 						dol_syslog($this->error, LOG_WARNING);
@@ -1116,8 +1135,12 @@  discard block
 block discarded – undo
1116 1135
 
1117 1136
 									//Date object
1118 1137
 									$dateref=$element->date;
1119
-									if (empty($dateref)) $dateref=$element->datep;
1120
-									if (empty($dateref)) $dateref=$element->date_contrat;
1138
+									if (empty($dateref)) {
1139
+									    $dateref=$element->datep;
1140
+									}
1141
+									if (empty($dateref)) {
1142
+									    $dateref=$element->date_contrat;
1143
+									}
1121 1144
 									$ref_array['date']=$dateref;
1122 1145
 
1123 1146
 									//Soc object
@@ -1150,12 +1173,10 @@  discard block
 block discarded – undo
1150 1173
 										try
1151 1174
 										{
1152 1175
 											$listlines->setVars($key, $val, true, 'UTF-8');
1153
-										}
1154
-										catch(OdfException $e)
1176
+										} catch(OdfException $e)
1155 1177
 										{
1156 1178
 											dol_syslog($e->getMessage(), LOG_INFO);
1157
-										}
1158
-										catch(SegmentException $e)
1179
+										} catch(SegmentException $e)
1159 1180
 										{
1160 1181
 											dol_syslog($e->getMessage(), LOG_INFO);
1161 1182
 										}
@@ -1208,16 +1229,16 @@  discard block
 block discarded – undo
1208 1229
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209 1230
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1210 1231
 
1211
-				if (! empty($conf->global->MAIN_UMASK))
1212
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
1232
+				if (! empty($conf->global->MAIN_UMASK)) {
1233
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
1234
+				}
1213 1235
 
1214 1236
 				$odfHandler=null;	// Destroy object
1215 1237
 
1216 1238
 				$this->result = array('fullpath'=>$file);
1217 1239
 
1218 1240
 				return 1;   // Success
1219
-			}
1220
-			else
1241
+			} else
1221 1242
 			{
1222 1243
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1223 1244
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/modules_project.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -31,33 +31,33 @@  discard block
 block discarded – undo
31 31
  */
32 32
 abstract class ModelePDFProjects extends CommonDocGenerator
33 33
 {
34
-	/**
35
-	 * @var string Error code (or message)
36
-	 */
37
-	public $error='';
34
+    /**
35
+     * @var string Error code (or message)
36
+     */
37
+    public $error='';
38 38
 
39 39
 
40 40
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
41 41
     /**
42
-	 *  Return list of active generation modules
43
-	 *
42
+     *  Return list of active generation modules
43
+     *
44 44
      *  @param  DoliDB	$db     			Database handler
45 45
      *  @param  integer	$maxfilenamelength  Max length of value to show
46 46
      *  @return	array						List of templates
47 47
      */
48
-	static function liste_modeles($db,$maxfilenamelength=0)
49
-	{
48
+    static function liste_modeles($db,$maxfilenamelength=0)
49
+    {
50 50
         // phpcs:enable
51
-		global $conf;
51
+        global $conf;
52 52
 
53
-		$type='project';
54
-		$liste=array();
53
+        $type='project';
54
+        $liste=array();
55 55
 
56
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
56
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
58 58
 
59
-		return $liste;
60
-	}
59
+        return $liste;
60
+    }
61 61
 }
62 62
 
63 63
 
@@ -67,83 +67,83 @@  discard block
 block discarded – undo
67 67
  */
68 68
 abstract class ModeleNumRefProjects
69 69
 {
70
-	/**
71
-	 * @var string Error code (or message)
72
-	 */
73
-	public $error='';
74
-
75
-	/**
76
-	 *  Return if a module can be used or not
77
-	 *
78
-	 *  @return		boolean     true if module can be used
79
-	 */
80
-	function isEnabled()
81
-	{
82
-		return true;
83
-	}
84
-
85
-	/**
86
-	 *  Renvoi la description par defaut du modele de numerotation
87
-	 *
88
-	 *  @return     string      Texte descripif
89
-	 */
90
-	function info()
91
-	{
92
-		global $langs;
93
-		$langs->load("projects");
94
-		return $langs->trans("NoDescription");
95
-	}
96
-
97
-	/**
98
-	 *  Renvoi un exemple de numerotation
99
-	 *
100
-	 *  @return     string      Example
101
-	 */
102
-	function getExample()
103
-	{
104
-		global $langs;
105
-		$langs->load("projects");
106
-		return $langs->trans("NoExample");
107
-	}
108
-
109
-	/**
110
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
111
-	 *  de conflits qui empechera cette numerotation de fonctionner.
112
-	 *
113
-	 *  @return     boolean     false si conflit, true si ok
114
-	 */
115
-	function canBeActivated()
116
-	{
117
-		return true;
118
-	}
119
-
120
-	/**
121
-	 *  Renvoi prochaine valeur attribuee
122
-	 *
123
-	 *	@param	Societe		$objsoc		Object third party
124
-	 *	@param	Project		$project	Object project
125
-	 *	@return	string					Valeur
126
-	 */
127
-	function getNextValue($objsoc, $project)
128
-	{
129
-		global $langs;
130
-		return $langs->trans("NotAvailable");
131
-	}
132
-
133
-	/**
134
-	 *  Renvoi version du module numerotation
135
-	 *
136
-	 *  @return     string      Valeur
137
-	 */
138
-	function getVersion()
139
-	{
140
-		global $langs;
141
-		$langs->load("admin");
142
-
143
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
144
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
145
-		if ($this->version == 'dolibarr') return DOL_VERSION;
146
-		if ($this->version) return $this->version;
147
-		return $langs->trans("NotAvailable");
148
-	}
70
+    /**
71
+     * @var string Error code (or message)
72
+     */
73
+    public $error='';
74
+
75
+    /**
76
+     *  Return if a module can be used or not
77
+     *
78
+     *  @return		boolean     true if module can be used
79
+     */
80
+    function isEnabled()
81
+    {
82
+        return true;
83
+    }
84
+
85
+    /**
86
+     *  Renvoi la description par defaut du modele de numerotation
87
+     *
88
+     *  @return     string      Texte descripif
89
+     */
90
+    function info()
91
+    {
92
+        global $langs;
93
+        $langs->load("projects");
94
+        return $langs->trans("NoDescription");
95
+    }
96
+
97
+    /**
98
+     *  Renvoi un exemple de numerotation
99
+     *
100
+     *  @return     string      Example
101
+     */
102
+    function getExample()
103
+    {
104
+        global $langs;
105
+        $langs->load("projects");
106
+        return $langs->trans("NoExample");
107
+    }
108
+
109
+    /**
110
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
111
+     *  de conflits qui empechera cette numerotation de fonctionner.
112
+     *
113
+     *  @return     boolean     false si conflit, true si ok
114
+     */
115
+    function canBeActivated()
116
+    {
117
+        return true;
118
+    }
119
+
120
+    /**
121
+     *  Renvoi prochaine valeur attribuee
122
+     *
123
+     *	@param	Societe		$objsoc		Object third party
124
+     *	@param	Project		$project	Object project
125
+     *	@return	string					Valeur
126
+     */
127
+    function getNextValue($objsoc, $project)
128
+    {
129
+        global $langs;
130
+        return $langs->trans("NotAvailable");
131
+    }
132
+
133
+    /**
134
+     *  Renvoi version du module numerotation
135
+     *
136
+     *  @return     string      Valeur
137
+     */
138
+    function getVersion()
139
+    {
140
+        global $langs;
141
+        $langs->load("admin");
142
+
143
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
144
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
145
+        if ($this->version == 'dolibarr') return DOL_VERSION;
146
+        if ($this->version) return $this->version;
147
+        return $langs->trans("NotAvailable");
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @var string Error code (or message)
36 36
 	 */
37
-	public $error='';
37
+	public $error = '';
38 38
 
39 39
 
40 40
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
      *  @param  integer	$maxfilenamelength  Max length of value to show
46 46
      *  @return	array						List of templates
47 47
      */
48
-	static function liste_modeles($db,$maxfilenamelength=0)
48
+	static function liste_modeles($db, $maxfilenamelength = 0)
49 49
 	{
50 50
         // phpcs:enable
51 51
 		global $conf;
52 52
 
53
-		$type='project';
54
-		$liste=array();
53
+		$type = 'project';
54
+		$liste = array();
55 55
 
56 56
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
57
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
58 58
 
59 59
 		return $liste;
60 60
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	/**
71 71
 	 * @var string Error code (or message)
72 72
 	 */
73
-	public $error='';
73
+	public $error = '';
74 74
 
75 75
 	/**
76 76
 	 *  Return if a module can be used or not
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.