Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/livraison/modules_livraison.php 3 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -36,32 +36,32 @@  discard block
 block discarded – undo
36 36
  */
37 37
 abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
38 38
 {
39
-	/**
40
-	 * @var string Error code (or message)
41
-	 */
42
-	public $error='';
39
+    /**
40
+     * @var string Error code (or message)
41
+     */
42
+    public $error='';
43 43
 
44 44
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
45
-	/**
46
-	 *  Return list of active generation modules
47
-	 *
45
+    /**
46
+     *  Return list of active generation modules
47
+     *
48 48
      *  @param	DoliDB	$db     			Database handler
49 49
      *  @param  integer	$maxfilenamelength  Max length of value to show
50 50
      *  @return	array						List of templates
51
-	 */
52
-	static function liste_modeles($db,$maxfilenamelength=0)
53
-	{
51
+     */
52
+    static function liste_modeles($db,$maxfilenamelength=0)
53
+    {
54 54
         // phpcs:enable
55
-		global $conf;
55
+        global $conf;
56 56
 
57
-		$type='delivery';
58
-		$liste=array();
57
+        $type='delivery';
58
+        $liste=array();
59 59
 
60
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
61
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
60
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
61
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
62 62
 
63
-		return $liste;
64
-	}
63
+        return $liste;
64
+    }
65 65
 }
66 66
 
67 67
 
@@ -72,83 +72,83 @@  discard block
 block discarded – undo
72 72
  */
73 73
 abstract class ModeleNumRefDeliveryOrder
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
-	 * Renvoi 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("deliveries");
99
-		return $langs->trans("NoDescription");
100
-	}
101
-
102
-	/**
103
-	 * Renvoi un exemple de numerotation
104
-	 *
105
-	 * @return     string      Example
106
-	 */
107
-	function getExample()
108
-	{
109
-		global $langs;
110
-		$langs->load("deliveries");
111
-		return $langs->trans("NoExample");
112
-	}
113
-
114
-	/**
115
-	 * Test si les numeros deja en vigueur dans la base ne provoquent pas d
116
-	 * de conflits qui empechera cette numerotation de fonctionner.
117
-	 *
118
-	 * @return     boolean     false si conflit, true si ok
119
-	 */
120
-	function canBeActivated()
121
-	{
122
-		return true;
123
-	}
124
-
125
-	/**
126
-	 * Renvoi prochaine valeur attribuee
127
-	 *
128
-	 *	@param	Societe		$objsoc     	Object third party
129
-	 *  @param  Object		$object			Object delivery
130
-	 *	@return	string						Valeur
131
-	 */
132
-	function getNextValue($objsoc, $object)
133
-	{
134
-		global $langs;
135
-		return $langs->trans("NotAvailable");
136
-	}
137
-
138
-	/**
139
-	 * Renvoi version du module numerotation
140
-	 *
141
-	 * @return     string      Valeur
142
-	 */
143
-	function getVersion()
144
-	{
145
-		global $langs;
146
-		$langs->load("admin");
147
-
148
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
149
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
150
-		if ($this->version == 'dolibarr') return DOL_VERSION;
151
-		if ($this->version) return $this->version;
152
-		return $langs->trans("NotAvailable");
153
-	}
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
+     * Renvoi 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("deliveries");
99
+        return $langs->trans("NoDescription");
100
+    }
101
+
102
+    /**
103
+     * Renvoi un exemple de numerotation
104
+     *
105
+     * @return     string      Example
106
+     */
107
+    function getExample()
108
+    {
109
+        global $langs;
110
+        $langs->load("deliveries");
111
+        return $langs->trans("NoExample");
112
+    }
113
+
114
+    /**
115
+     * Test si les numeros deja en vigueur dans la base ne provoquent pas d
116
+     * de conflits qui empechera cette numerotation de fonctionner.
117
+     *
118
+     * @return     boolean     false si conflit, true si ok
119
+     */
120
+    function canBeActivated()
121
+    {
122
+        return true;
123
+    }
124
+
125
+    /**
126
+     * Renvoi prochaine valeur attribuee
127
+     *
128
+     *	@param	Societe		$objsoc     	Object third party
129
+     *  @param  Object		$object			Object delivery
130
+     *	@return	string						Valeur
131
+     */
132
+    function getNextValue($objsoc, $object)
133
+    {
134
+        global $langs;
135
+        return $langs->trans("NotAvailable");
136
+    }
137
+
138
+    /**
139
+     * Renvoi version du module numerotation
140
+     *
141
+     * @return     string      Valeur
142
+     */
143
+    function getVersion()
144
+    {
145
+        global $langs;
146
+        $langs->load("admin");
147
+
148
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
149
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
150
+        if ($this->version == 'dolibarr') return DOL_VERSION;
151
+        if ($this->version) return $this->version;
152
+        return $langs->trans("NotAvailable");
153
+    }
154 154
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @var string Error code (or message)
41 41
 	 */
42
-	public $error='';
42
+	public $error = '';
43 43
 
44 44
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
45 45
 	/**
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
      *  @param  integer	$maxfilenamelength  Max length of value to show
50 50
      *  @return	array						List of templates
51 51
 	 */
52
-	static function liste_modeles($db,$maxfilenamelength=0)
52
+	static function liste_modeles($db, $maxfilenamelength = 0)
53 53
 	{
54 54
         // phpcs:enable
55 55
 		global $conf;
56 56
 
57
-		$type='delivery';
58
-		$liste=array();
57
+		$type = 'delivery';
58
+		$liste = array();
59 59
 
60 60
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
61
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
61
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
62 62
 
63 63
 		return $liste;
64 64
 	}
@@ -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
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/livraison/mod_livraison_saphir.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -31,28 +31,28 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	/**
41
-	 * @var string Error message
42
-	 */
43
-	public $error = '';
40
+    /**
41
+     * @var string Error message
42
+     */
43
+    public $error = '';
44 44
 
45
-	/**
46
-	 * @var string Nom du modele
47
-	 * @deprecated
48
-	 * @see name
49
-	 */
50
-	public $nom='Saphir';
45
+    /**
46
+     * @var string Nom du modele
47
+     * @deprecated
48
+     * @see name
49
+     */
50
+    public $nom='Saphir';
51 51
 
52
-	/**
53
-	 * @var string model name
54
-	 */
55
-	public $name='Saphir';
52
+    /**
53
+     * @var string model name
54
+     */
55
+    public $name='Saphir';
56 56
 
57 57
 
58 58
     /**
@@ -60,39 +60,39 @@  discard block
 block discarded – undo
60 60
      *
61 61
      *  @return     string      Texte descripif
62 62
      */
63
-	function info()
64
-	{
65
-    	global $conf, $langs;
63
+    function info()
64
+    {
65
+        global $conf, $langs;
66 66
 
67
-		$langs->load("bills");
67
+        $langs->load("bills");
68 68
 
69
-		$form = new Form($this->db);
69
+        $form = new Form($this->db);
70 70
 
71
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
75
-		$texte.= '<input type="hidden" name="maskconstdelivery" value="LIVRAISON_SAPHIR_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
71
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
75
+        $texte.= '<input type="hidden" name="maskconstdelivery" value="LIVRAISON_SAPHIR_MASK">';
76
+        $texte.= '<table class="nobordernopadding" width="100%">';
77 77
 
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
78
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery"));
79
+        $tooltip.=$langs->trans("GenericMaskCodes2");
80
+        $tooltip.=$langs->trans("GenericMaskCodes3");
81
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery"));
82
+        $tooltip.=$langs->trans("GenericMaskCodes5");
83 83
 
84
-		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->LIVRAISON_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
84
+        // Parametrage du prefix
85
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->LIVRAISON_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+        $texte.= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+        $texte.= '</table>';
93
+        $texte.= '</form>';
94 94
 
95
-		return $texte;
95
+        return $texte;
96 96
     }
97 97
 
98 98
     /**
@@ -102,54 +102,54 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-     	global $conf,$langs,$mysoc;
106
-
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-		$numExample = $this->getNextValue($mysoc,'');
110
-    	$mysoc->code_client=$old_code_client;
111
-
112
-		if (! $numExample)
113
-		{
114
-			$numExample = $langs->trans('NotConfigured');
115
-		}
116
-		return $numExample;
105
+            global $conf,$langs,$mysoc;
106
+
107
+        $old_code_client=$mysoc->code_client;
108
+        $mysoc->code_client='CCCCCCCCCC';
109
+        $numExample = $this->getNextValue($mysoc,'');
110
+        $mysoc->code_client=$old_code_client;
111
+
112
+        if (! $numExample)
113
+        {
114
+            $numExample = $langs->trans('NotConfigured');
115
+        }
116
+        return $numExample;
117 117
     }
118 118
 
119 119
 
120
-	/**
121
-	 *  Return next value
122
-	 *
123
-	 *  @param	Societe		$objsoc     	Object third party
124
-	 *  @param  Object		$object			Object delivery
125
-	 *  @return string      				Value if OK, 0 if KO
126
-	 */
120
+    /**
121
+     *  Return next value
122
+     *
123
+     *  @param	Societe		$objsoc     	Object third party
124
+     *  @param  Object		$object			Object delivery
125
+     *  @return string      				Value if OK, 0 if KO
126
+     */
127 127
     function getNextValue($objsoc,$object)
128 128
     {
129
-		global $db,$conf;
129
+        global $db,$conf;
130 130
 
131
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
131
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
132 132
 
133
-		// On defini critere recherche compteur
134
-		$mask=$conf->global->LIVRAISON_SAPHIR_MASK;
133
+        // On defini critere recherche compteur
134
+        $mask=$conf->global->LIVRAISON_SAPHIR_MASK;
135 135
 
136
-		if (! $mask)
137
-		{
138
-			$this->error='NotConfigured';
139
-			return 0;
140
-		}
136
+        if (! $mask)
137
+        {
138
+            $this->error='NotConfigured';
139
+            return 0;
140
+        }
141 141
 
142
-		$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison);
142
+        $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison);
143 143
 
144
-		return  $numFinal;
144
+        return  $numFinal;
145 145
     }
146 146
 
147 147
 
148
-	/**
149
-	 *  Return next free value
150
-	 *
148
+    /**
149
+     *  Return next free value
150
+     *
151 151
      *  @param	Societe		$objsoc     Object third party
152
-	 * 	@param	string		$objforref	Object for number to search
152
+     * 	@param	string		$objforref	Object for number to search
153 153
      *  @return string      			Next free value
154 154
      */
155 155
     function getNumRef($objsoc,$objforref)
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\ingroup    expedition
24 24
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de livraison Saphir
25 25
  */
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/modules_livraison.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
27 27
 
28 28
 /**
29 29
  *	\class      mod_livraison_saphir
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40 40
 	/**
41 41
 	 * @var string Error message
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 	 * @deprecated
48 48
 	 * @see name
49 49
 	 */
50
-	public $nom='Saphir';
50
+	public $nom = 'Saphir';
51 51
 
52 52
 	/**
53 53
 	 * @var string model name
54 54
 	 */
55
-	public $name='Saphir';
55
+	public $name = 'Saphir';
56 56
 
57 57
 
58 58
     /**
@@ -69,28 +69,28 @@  discard block
 block discarded – undo
69 69
 		$form = new Form($this->db);
70 70
 
71 71
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
75
-		$texte.= '<input type="hidden" name="maskconstdelivery" value="LIVRAISON_SAPHIR_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
77
-
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Delivery"),$langs->transnoentities("Delivery"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
72
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
75
+		$texte .= '<input type="hidden" name="maskconstdelivery" value="LIVRAISON_SAPHIR_MASK">';
76
+		$texte .= '<table class="nobordernopadding" width="100%">';
77
+
78
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery"));
79
+		$tooltip .= $langs->trans("GenericMaskCodes2");
80
+		$tooltip .= $langs->trans("GenericMaskCodes3");
81
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery"));
82
+		$tooltip .= $langs->trans("GenericMaskCodes5");
83 83
 
84 84
 		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->LIVRAISON_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
85
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->LIVRAISON_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+		$texte .= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+		$texte .= '</table>';
93
+		$texte .= '</form>';
94 94
 
95 95
 		return $texte;
96 96
     }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-     	global $conf,$langs,$mysoc;
105
+     	global $conf, $langs, $mysoc;
106 106
 
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-		$numExample = $this->getNextValue($mysoc,'');
110
-    	$mysoc->code_client=$old_code_client;
107
+    	$old_code_client = $mysoc->code_client;
108
+    	$mysoc->code_client = 'CCCCCCCCCC';
109
+		$numExample = $this->getNextValue($mysoc, '');
110
+    	$mysoc->code_client = $old_code_client;
111 111
 
112
-		if (! $numExample)
112
+		if (!$numExample)
113 113
 		{
114 114
 			$numExample = $langs->trans('NotConfigured');
115 115
 		}
@@ -124,22 +124,22 @@  discard block
 block discarded – undo
124 124
 	 *  @param  Object		$object			Object delivery
125 125
 	 *  @return string      				Value if OK, 0 if KO
126 126
 	 */
127
-    function getNextValue($objsoc,$object)
127
+    function getNextValue($objsoc, $object)
128 128
     {
129
-		global $db,$conf;
129
+		global $db, $conf;
130 130
 
131
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
131
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
132 132
 
133 133
 		// On defini critere recherche compteur
134
-		$mask=$conf->global->LIVRAISON_SAPHIR_MASK;
134
+		$mask = $conf->global->LIVRAISON_SAPHIR_MASK;
135 135
 
136
-		if (! $mask)
136
+		if (!$mask)
137 137
 		{
138
-			$this->error='NotConfigured';
138
+			$this->error = 'NotConfigured';
139 139
 			return 0;
140 140
 		}
141 141
 
142
-		$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison);
142
+		$numFinal = get_next_value($db, $mask, 'livraison', 'ref', '', $objsoc, $object->date_livraison);
143 143
 
144 144
 		return  $numFinal;
145 145
     }
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 * 	@param	string		$objforref	Object for number to search
153 153
      *  @return string      			Next free value
154 154
      */
155
-    function getNumRef($objsoc,$objforref)
155
+    function getNumRef($objsoc, $objforref)
156 156
     {
157
-        return $this->getNextValue($objsoc,$objforref);
157
+        return $this->getNextValue($objsoc, $objforref);
158 158
     }
159 159
 
160 160
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
      *  @param  Object		$object			Objet livraison
167 167
      *  @return string      				Texte descripif
168 168
      */
169
-    function livraison_get_num($objsoc=0,$object='')
169
+    function livraison_get_num($objsoc = 0, $object = '')
170 170
     {
171 171
         // phpcs:enable
172
-        return $this->getNextValue($objsoc,$object);
172
+        return $this->getNextValue($objsoc, $object);
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modStripe.class.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
         // Main menu entries
94 94
         $r=0;
95
-       /* $this->menu[$r]=array(
95
+        /* $this->menu[$r]=array(
96 96
         	'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
97 97
 	        'mainmenu'=>'billing',
98 98
         	'leftmenu'=>'customers_bills_payment_stripe',
@@ -109,47 +109,47 @@  discard block
 block discarded – undo
109 109
         $r++;*/
110 110
 
111 111
         $this->menu[$r] = array(
112
-        	'fk_menu'=>'fk_mainmenu=bank',
113
-			'type'=>'left',
114
-			'titre'=>'StripeAccount',
115
-			'mainmenu'=>'bank',
116
-			'leftmenu'=>'stripe',
117
-			'url' => '',
118
-			'langs' => 'stripe',
119
-			'position' => 100,
120
-			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
121
-			'perms' => '$user->rights->banque->lire',
122
-			'target' => '',
123
-			'user' => 0
124
-		);
112
+            'fk_menu'=>'fk_mainmenu=bank',
113
+            'type'=>'left',
114
+            'titre'=>'StripeAccount',
115
+            'mainmenu'=>'bank',
116
+            'leftmenu'=>'stripe',
117
+            'url' => '',
118
+            'langs' => 'stripe',
119
+            'position' => 100,
120
+            'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
121
+            'perms' => '$user->rights->banque->lire',
122
+            'target' => '',
123
+            'user' => 0
124
+        );
125 125
 
126 126
         $r++;
127
-		$this->menu[$r] = array(
128
-			'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
129
-			'type' => 'left',
130
-			'titre' => 'StripeChargeList',
131
-			'url' => '/stripe/charge.php',
132
-			'langs' => 'stripe',
133
-			'position' => 102,
134
-			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
135
-			'perms' => '$user->rights->banque->lire',
136
-			'target' => '',
137
-			'user' => 0
138
-		);
127
+        $this->menu[$r] = array(
128
+            'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
129
+            'type' => 'left',
130
+            'titre' => 'StripeChargeList',
131
+            'url' => '/stripe/charge.php',
132
+            'langs' => 'stripe',
133
+            'position' => 102,
134
+            'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
135
+            'perms' => '$user->rights->banque->lire',
136
+            'target' => '',
137
+            'user' => 0
138
+        );
139 139
 
140 140
         $r++;
141
-		$this->menu[$r] = array(
142
-			'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
143
-			'type' => 'left',
144
-			'titre' => 'StripeTransactionList',
145
-			'url' => '/stripe/transaction.php',
146
-			'langs' => 'stripe',
147
-			'position' => 102,
148
-			'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
149
-			'perms' => '$user->rights->banque->lire',
150
-			'target' => '',
151
-			'user' => 0
152
-		);
141
+        $this->menu[$r] = array(
142
+            'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
143
+            'type' => 'left',
144
+            'titre' => 'StripeTransactionList',
145
+            'url' => '/stripe/transaction.php',
146
+            'langs' => 'stripe',
147
+            'position' => 102,
148
+            'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
149
+            'perms' => '$user->rights->banque->lire',
150
+            'target' => '',
151
+            'user' => 0
152
+        );
153 153
 
154 154
         // Exports
155 155
         $r=1;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *  \ingroup    stripe
24 24
  *  \brief      Description and activation file for module Stripe
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 
29 29
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         // It is used to group modules in module setup page
51 51
         $this->family = "interface";
52 52
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-        $this->name = preg_replace('/^mod/i','',get_class($this));
53
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
         // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
55 55
         $this->description = "Module to offer an online payment page by credit card with Stripe";
56 56
         // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         // Name of image file used for this module.
61 61
         // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
62 62
         // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'
63
-        $this->picto='stripe';
63
+        $this->picto = 'stripe';
64 64
 
65 65
         // Data directories to create when module is enabled.
66 66
         $this->dirs = array();
@@ -69,29 +69,29 @@  discard block
 block discarded – undo
69 69
         $this->config_page_url = array("stripe.php@stripe");
70 70
 
71 71
         // Dependencies
72
-        $this->hidden = false;			// A condition to hide module
73
-        $this->depends = array();		// List of modules id that must be enabled if this module is enabled
74
-        $this->requiredby = array();	// List of modules id to disable if this one is disabled
75
-        $this->phpmin = array(5,4);					// Minimum version of PHP required by module
76
-        $this->need_dolibarr_version = array(5,0);	// Minimum version of Dolibarr required by module
72
+        $this->hidden = false; // A condition to hide module
73
+        $this->depends = array(); // List of modules id that must be enabled if this module is enabled
74
+        $this->requiredby = array(); // List of modules id to disable if this one is disabled
75
+        $this->phpmin = array(5, 4); // Minimum version of PHP required by module
76
+        $this->need_dolibarr_version = array(5, 0); // Minimum version of Dolibarr required by module
77 77
         $this->langfiles = array("stripe");
78 78
 
79 79
         // Constants
80
-        $this->const = array();			// List of particular constants to add when module is enabled
80
+        $this->const = array(); // List of particular constants to add when module is enabled
81 81
 
82 82
         // New pages on tabs
83 83
         $this->tabs = array();
84 84
 
85 85
         // Boxes
86
-        $this->boxes = array();			// List of boxes
87
-        $r=0;
86
+        $this->boxes = array(); // List of boxes
87
+        $r = 0;
88 88
 
89 89
         // Permissions
90
-        $this->rights = array();		// Permission array used by this module
91
-        $r=0;
90
+        $this->rights = array(); // Permission array used by this module
91
+        $r = 0;
92 92
 
93 93
         // Main menu entries
94
-        $r=0;
94
+        $r = 0;
95 95
        /* $this->menu[$r]=array(
96 96
         	'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
97 97
 	        'mainmenu'=>'billing',
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		);
153 153
 
154 154
         // Exports
155
-        $r=1;
155
+        $r = 1;
156 156
     }
157 157
 }
158 158
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modReceiptPrinter.class.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $this->name = preg_replace('/^mod/i','',get_class($this));
53 53
         // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
54 54
         $this->description = "ReceiptPrinterDesc";
55
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
55
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
56 56
         $this->version = 'development';
57 57
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58 58
         // Name of image file used for this module.
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 
69 69
         // Dependencies
70 70
         $this->hidden = false;			// A condition to hide module
71
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
72
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
73
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
74
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
71
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
72
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
73
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
74
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
75 75
         $this->need_dolibarr_version = array(3,9,-2);   // Minimum version of Dolibarr required by module
76 76
         $this->conflictwith = array();
77 77
         $this->langfiles = array("receiptprinter");
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *  \ingroup    printing
26 26
  *  \brief      File of class to describe and activate module Receipt Printer
27 27
  */
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 
31 31
 
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
      */
43 43
     function __construct($db)
44 44
     {
45
-        $this->db = $db ;
45
+        $this->db = $db;
46 46
         $this->numero = 67000;
47 47
         // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
48 48
         // It is used to group modules in module setup page
49 49
         $this->family = "interface";
50 50
         $this->module_position = '53';
51 51
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
-        $this->name = preg_replace('/^mod/i','',get_class($this));
52
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
53 53
         // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
54 54
         $this->description = "ReceiptPrinterDesc";
55 55
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
         $this->config_page_url = array("receiptprinter.php");
68 68
 
69 69
         // Dependencies
70
-        $this->hidden = false;			// A condition to hide module
71
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
72
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
73
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
74
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
75
-        $this->need_dolibarr_version = array(3,9,-2);   // Minimum version of Dolibarr required by module
70
+        $this->hidden = false; // A condition to hide module
71
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
72
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
73
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
74
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
75
+        $this->need_dolibarr_version = array(3, 9, -2); // Minimum version of Dolibarr required by module
76 76
         $this->conflictwith = array();
77 77
         $this->langfiles = array("receiptprinter");
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $this->rights = array();
87 87
         $this->rights_class = 'receiptprinter';
88 88
 
89
-        $r=0;
89
+        $r = 0;
90 90
         // $this->rights[$r][0]     Id permission (unique tous modules confondus)
91 91
         // $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
92 92
         // $this->rights[$r][2]     Non utilise
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
         $this->rights[$r][4] = 'read';
103 103
 
104 104
         // Main menu entries
105
-        $this->menus = array();         // List of menus to add
106
-        $r=0;
105
+        $this->menus = array(); // List of menus to add
106
+        $r = 0;
107 107
 
108 108
         // This is to declare the Top Menu entry:
109 109
         //$this->menu[$r]=array(  'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',               // Put 0 if this is a top menu
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      *      @param      string  $options    Options when enabling module ('', 'noboxes')
131 131
      *      @return     int                 1 if OK, 0 if KO
132 132
      */
133
-    function init($options='')
133
+    function init($options = '')
134 134
     {
135 135
         global $conf;
136 136
         // Clean before activation
@@ -139,6 +139,6 @@  discard block
 block discarded – undo
139 139
             "CREATE TABLE IF NOT EXISTS llx_printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;",
140 140
             "CREATE TABLE IF NOT EXISTS llx_printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;",
141 141
             );
142
-        return $this->_init($sql,$options);
142
+        return $this->_init($sql, $options);
143 143
     }
144 144
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modComptabilite.class.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -35,89 +35,89 @@
 block discarded – undo
35 35
 class modComptabilite extends DolibarrModules
36 36
 {
37 37
 
38
-   /**
39
-	 *   Constructor. Define names, constants, directories, boxes, permissions
40
-	 *
41
-	 *   @param      DoliDB		$db      Database handler
42
-    */
43
-	function __construct($db)
44
-	{
45
-		global $conf;
46
-
47
-		$this->db = $db;
48
-		$this->numero = 10;
49
-
50
-		$this->family = "financial";
51
-		$this->module_position = '60';
52
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
-		$this->description = "Gestion sommaire de comptabilite";
55
-
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
38
+    /**
39
+     *   Constructor. Define names, constants, directories, boxes, permissions
40
+     *
41
+     *   @param      DoliDB		$db      Database handler
42
+     */
43
+    function __construct($db)
44
+    {
45
+        global $conf;
46
+
47
+        $this->db = $db;
48
+        $this->numero = 10;
49
+
50
+        $this->family = "financial";
51
+        $this->module_position = '60';
52
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
+        $this->name = preg_replace('/^mod/i','',get_class($this));
54
+        $this->description = "Gestion sommaire de comptabilite";
55
+
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
         $this->picto='accounting';
61 61
 
62
-		// Config pages
63
-		$this->config_page_url = array("compta.php");
64
-
65
-		// Dependencies
66
-		$this->depends = array("modFacture","modBanque");
67
-		$this->requiredby = array();
68
-		$this->conflictwith = array("modAccounting");
69
-		$this->langfiles = array("compta");
70
-
71
-		// Constants
72
-		$this->const = array();
73
-
74
-		// Data directories to create when module is enabled
75
-		$this->dirs = array("/comptabilite/temp",
76
-		                    "/comptabilite/rapport",
77
-		                    "/comptabilite/export",
78
-		                    "/comptabilite/bordereau"
79
-		                    );
80
-
81
-		// Boxes
82
-		$this->boxes = array();
83
-
84
-		// Permissions
85
-		$this->rights = array();
86
-		$this->rights_class = 'compta';
87
-		$r=0;
88
-
89
-		$r++;
90
-		$this->rights[$r][0] = 95;
91
-		$this->rights[$r][1] = 'Lire CA, bilans, resultats';
92
-		$this->rights[$r][2] = 'r';
93
-		$this->rights[$r][3] = 0;
94
-		$this->rights[$r][4] = 'resultat';
95
-		$this->rights[$r][5] = 'lire';
96
-
97
-
98
-		// Menus
99
-		//-------
100
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
101
-	}
102
-
103
-
104
-   /**
105
-	 *		Function called when module is enabled.
106
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
107
-	 *		It also creates data directories
108
-	 *
62
+        // Config pages
63
+        $this->config_page_url = array("compta.php");
64
+
65
+        // Dependencies
66
+        $this->depends = array("modFacture","modBanque");
67
+        $this->requiredby = array();
68
+        $this->conflictwith = array("modAccounting");
69
+        $this->langfiles = array("compta");
70
+
71
+        // Constants
72
+        $this->const = array();
73
+
74
+        // Data directories to create when module is enabled
75
+        $this->dirs = array("/comptabilite/temp",
76
+                            "/comptabilite/rapport",
77
+                            "/comptabilite/export",
78
+                            "/comptabilite/bordereau"
79
+                            );
80
+
81
+        // Boxes
82
+        $this->boxes = array();
83
+
84
+        // Permissions
85
+        $this->rights = array();
86
+        $this->rights_class = 'compta';
87
+        $r=0;
88
+
89
+        $r++;
90
+        $this->rights[$r][0] = 95;
91
+        $this->rights[$r][1] = 'Lire CA, bilans, resultats';
92
+        $this->rights[$r][2] = 'r';
93
+        $this->rights[$r][3] = 0;
94
+        $this->rights[$r][4] = 'resultat';
95
+        $this->rights[$r][5] = 'lire';
96
+
97
+
98
+        // Menus
99
+        //-------
100
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
101
+    }
102
+
103
+
104
+    /**
105
+     *		Function called when module is enabled.
106
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
107
+     *		It also creates data directories
108
+     *
109 109
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
110
-	 *      @return     int             	1 if OK, 0 if KO
111
-    */
112
-	function init($options='')
113
-	{
114
-		global $conf;
110
+     *      @return     int             	1 if OK, 0 if KO
111
+     */
112
+    function init($options='')
113
+    {
114
+        global $conf;
115 115
 
116
-		// Nettoyage avant activation
117
-		$this->remove($options);
116
+        // Nettoyage avant activation
117
+        $this->remove($options);
118 118
 
119
-		$sql = array();
119
+        $sql = array();
120 120
 
121
-		return $this->_init($sql,$options);
122
-	}
121
+        return $this->_init($sql,$options);
122
+    }
123 123
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * \brief      Fichier de description et activation du module Comptabilite
27 27
  */
28 28
 
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 		$this->family = "financial";
51 51
 		$this->module_position = '60';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Gestion sommaire de comptabilite";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57 57
 		$this->version = 'dolibarr';
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-        $this->picto='accounting';
60
+        $this->picto = 'accounting';
61 61
 
62 62
 		// Config pages
63 63
 		$this->config_page_url = array("compta.php");
64 64
 
65 65
 		// Dependencies
66
-		$this->depends = array("modFacture","modBanque");
66
+		$this->depends = array("modFacture", "modBanque");
67 67
 		$this->requiredby = array();
68 68
 		$this->conflictwith = array("modAccounting");
69 69
 		$this->langfiles = array("compta");
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		// Permissions
85 85
 		$this->rights = array();
86 86
 		$this->rights_class = 'compta';
87
-		$r=0;
87
+		$r = 0;
88 88
 
89 89
 		$r++;
90 90
 		$this->rights[$r][0] = 95;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 		// Menus
99 99
 		//-------
100
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
100
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
101 101
 	}
102 102
 
103 103
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
110 110
 	 *      @return     int             	1 if OK, 0 if KO
111 111
     */
112
-	function init($options='')
112
+	function init($options = '')
113 113
 	{
114 114
 		global $conf;
115 115
 
@@ -118,6 +118,6 @@  discard block
 block discarded – undo
118 118
 
119 119
 		$sql = array();
120 120
 
121
-		return $this->_init($sql,$options);
121
+		return $this->_init($sql, $options);
122 122
 	}
123 123
 }
Please login to merge, or discard this patch.
htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php 3 patches
Indentation   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -38,495 +38,495 @@
 block discarded – undo
38 38
  */
39 39
 class doc_generic_usergroup_odt extends ModelePDFUserGroup
40 40
 {
41
-	/**
42
-	 * Issuer
43
-	 * @var Societe
44
-	 */
45
-	public $emetteur;
46
-
47
-	/**
48
-   * @var array() Minimum version of PHP required by module.
49
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
50
-   */
51
-	public $phpmin = array(5, 4);
52
-
53
-	/**
54
-   * Dolibarr version of the loaded document
55
-   * @public string
56
-   */
57
-	public $version = 'dolibarr';
58
-
59
-
60
-	/**
61
-	 *	Constructor
62
-	 *
63
-	 *  @param		DoliDB		$db      Database handler
64
-	 */
65
-	function __construct($db)
66
-	{
67
-		global $conf, $langs, $mysoc;
68
-
69
-		// Load translation files required by the page
41
+    /**
42
+     * Issuer
43
+     * @var Societe
44
+     */
45
+    public $emetteur;
46
+
47
+    /**
48
+     * @var array() Minimum version of PHP required by module.
49
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
50
+     */
51
+    public $phpmin = array(5, 4);
52
+
53
+    /**
54
+     * Dolibarr version of the loaded document
55
+     * @public string
56
+     */
57
+    public $version = 'dolibarr';
58
+
59
+
60
+    /**
61
+     *	Constructor
62
+     *
63
+     *  @param		DoliDB		$db      Database handler
64
+     */
65
+    function __construct($db)
66
+    {
67
+        global $conf, $langs, $mysoc;
68
+
69
+        // Load translation files required by the page
70 70
     $langs->loadLangs(array("main","companies"));
71 71
 
72
-		$this->db = $db;
73
-		$this->name = "ODT templates";
74
-		$this->description = $langs->trans("DocumentModelOdt");
75
-		$this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
-
77
-		// Dimension page pour format A4
78
-		$this->type = 'odt';
79
-		$this->page_largeur = 0;
80
-		$this->page_hauteur = 0;
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=0;
83
-		$this->marge_droite=0;
84
-		$this->marge_haute=0;
85
-		$this->marge_basse=0;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 0;                     // Gere option tva USERGROUP_TVAOPTION
89
-		$this->option_modereg = 0;                 // Affiche mode reglement
90
-		$this->option_condreg = 0;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 0;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
-
98
-		// Recupere emetteur
99
-		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
-	}
102
-
103
-
104
-	/**
105
-	 *	Return description of a module
106
-	 *
107
-	 *	@param	Translate	$langs      Lang object to use for output
108
-	 *	@return string       			Description
109
-	 */
110
-	function info($langs)
111
-	{
112
-		global $conf,$langs;
113
-
114
-		// Load translation files required by the page
72
+        $this->db = $db;
73
+        $this->name = "ODT templates";
74
+        $this->description = $langs->trans("DocumentModelOdt");
75
+        $this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
+
77
+        // Dimension page pour format A4
78
+        $this->type = 'odt';
79
+        $this->page_largeur = 0;
80
+        $this->page_hauteur = 0;
81
+        $this->format = array($this->page_largeur,$this->page_hauteur);
82
+        $this->marge_gauche=0;
83
+        $this->marge_droite=0;
84
+        $this->marge_haute=0;
85
+        $this->marge_basse=0;
86
+
87
+        $this->option_logo = 1;                    // Affiche logo
88
+        $this->option_tva = 0;                     // Gere option tva USERGROUP_TVAOPTION
89
+        $this->option_modereg = 0;                 // Affiche mode reglement
90
+        $this->option_condreg = 0;                 // Affiche conditions reglement
91
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
92
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
93
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
94
+        $this->option_credit_note = 0;             // Support credit notes
95
+        $this->option_freetext = 1;				   // Support add of a personalised text
96
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
+
98
+        // Recupere emetteur
99
+        $this->emetteur=$mysoc;
100
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+    }
102
+
103
+
104
+    /**
105
+     *	Return description of a module
106
+     *
107
+     *	@param	Translate	$langs      Lang object to use for output
108
+     *	@return string       			Description
109
+     */
110
+    function info($langs)
111
+    {
112
+        global $conf,$langs;
113
+
114
+        // Load translation files required by the page
115 115
         $langs->loadLangs(array("errors","companies"));
116 116
 
117
-		$form = new Form($this->db);
118
-
119
-		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
-		$texte.= '<input type="hidden" name="param1" value="USERGROUP_ADDON_PDF_ODT_PATH">';
124
-		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
125
-		{
126
-			$texte.= '<input type="hidden" name="param2" value="USERGROUP_ADDON_PDF_ODT_DEFAULT">';
127
-			$texte.= '<input type="hidden" name="param3" value="USERGROUP_ADDON_PDF_ODT_TOBILL">';
128
-			$texte.= '<input type="hidden" name="param4" value="USERGROUP_ADDON_PDF_ODT_CLOSED">';
129
-		}
130
-		$texte.= '<table class="nobordernopadding" width="100%">';
131
-
132
-		// List of directories area
133
-		$texte.= '<tr><td>';
134
-		$texttitle=$langs->trans("ListOfDirectories");
135
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH)));
136
-		$listoffiles=array();
137
-		foreach($listofdir as $key=>$tmpdir)
138
-		{
139
-			$tmpdir=trim($tmpdir);
140
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
-			if (! $tmpdir) {
142
-				unset($listofdir[$key]); continue;
143
-			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
-			else
146
-			{
147
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149
-			}
150
-		}
151
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152
-		// Add list of substitution keys
153
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
-
156
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
159
-		$texte.=$conf->global->USERGROUP_ADDON_PDF_ODT_PATH;
160
-		$texte.= '</textarea>';
161
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
-		$texte.= '<br></div></div>';
164
-
165
-		// Scan directories
166
-		if (count($listofdir))
167
-		{
168
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
169
-
170
-			if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
171
-			{
172
-				// Model for creation
173
-				$liste=ModelePDFUserGroup::liste_modeles($this->db);
174
-				$texte.= '<table width="50%;">';
175
-				$texte.= '<tr>';
176
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
177
-				$texte.= '<td colspan="">';
178
-				$texte.= $form->selectarray('value2',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT);
179
-				$texte.= "</td></tr>";
180
-
181
-				$texte.= '<tr>';
182
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
183
-				$texte.= '<td colspan="">';
184
-				$texte.= $form->selectarray('value3',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL);
185
-				$texte.= "</td></tr>";
186
-				$texte.= '<tr>';
187
-
188
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
189
-				$texte.= '<td colspan="">';
190
-				$texte.= $form->selectarray('value4',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED);
191
-				$texte.= "</td></tr>";
192
-				$texte.= '</table>';
193
-			}
194
-		}
195
-
196
-		$texte.= '</td>';
197
-
198
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
199
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
200
-		$texte.= '</td>';
201
-		$texte.= '</tr>';
202
-
203
-		$texte.= '</table>';
204
-		$texte.= '</form>';
205
-
206
-		return $texte;
207
-	}
117
+        $form = new Form($this->db);
118
+
119
+        $texte = $this->description.".<br>\n";
120
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
+        $texte.= '<input type="hidden" name="param1" value="USERGROUP_ADDON_PDF_ODT_PATH">';
124
+        if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
125
+        {
126
+            $texte.= '<input type="hidden" name="param2" value="USERGROUP_ADDON_PDF_ODT_DEFAULT">';
127
+            $texte.= '<input type="hidden" name="param3" value="USERGROUP_ADDON_PDF_ODT_TOBILL">';
128
+            $texte.= '<input type="hidden" name="param4" value="USERGROUP_ADDON_PDF_ODT_CLOSED">';
129
+        }
130
+        $texte.= '<table class="nobordernopadding" width="100%">';
131
+
132
+        // List of directories area
133
+        $texte.= '<tr><td>';
134
+        $texttitle=$langs->trans("ListOfDirectories");
135
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH)));
136
+        $listoffiles=array();
137
+        foreach($listofdir as $key=>$tmpdir)
138
+        {
139
+            $tmpdir=trim($tmpdir);
140
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
+            if (! $tmpdir) {
142
+                unset($listofdir[$key]); continue;
143
+            }
144
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+            else
146
+            {
147
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149
+            }
150
+        }
151
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152
+        // Add list of substitution keys
153
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
+
156
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
159
+        $texte.=$conf->global->USERGROUP_ADDON_PDF_ODT_PATH;
160
+        $texte.= '</textarea>';
161
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
+        $texte.= '<br></div></div>';
164
+
165
+        // Scan directories
166
+        if (count($listofdir))
167
+        {
168
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
169
+
170
+            if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
171
+            {
172
+                // Model for creation
173
+                $liste=ModelePDFUserGroup::liste_modeles($this->db);
174
+                $texte.= '<table width="50%;">';
175
+                $texte.= '<tr>';
176
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
177
+                $texte.= '<td colspan="">';
178
+                $texte.= $form->selectarray('value2',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT);
179
+                $texte.= "</td></tr>";
180
+
181
+                $texte.= '<tr>';
182
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
183
+                $texte.= '<td colspan="">';
184
+                $texte.= $form->selectarray('value3',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL);
185
+                $texte.= "</td></tr>";
186
+                $texte.= '<tr>';
187
+
188
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
189
+                $texte.= '<td colspan="">';
190
+                $texte.= $form->selectarray('value4',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED);
191
+                $texte.= "</td></tr>";
192
+                $texte.= '</table>';
193
+            }
194
+        }
195
+
196
+        $texte.= '</td>';
197
+
198
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
199
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
200
+        $texte.= '</td>';
201
+        $texte.= '</tr>';
202
+
203
+        $texte.= '</table>';
204
+        $texte.= '</form>';
205
+
206
+        return $texte;
207
+    }
208 208
 
209 209
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
210
-	/**
211
-	 *	Function to build a document on disk using the generic odt module.
212
-	 *
213
-	 *	@param		UserGroup		$object				Object source to build document
214
-	 *	@param		Translate	$outputlangs		Lang output object
215
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
216
-	 *  @param		int			$hidedetails		Do not show line details
217
-	 *  @param		int			$hidedesc			Do not show desc
218
-	 *  @param		int			$hideref			Do not show ref
219
-	 *	@return		int         					1 if OK, <=0 if KO
220
-	 */
221
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
222
-	{
210
+    /**
211
+     *	Function to build a document on disk using the generic odt module.
212
+     *
213
+     *	@param		UserGroup		$object				Object source to build document
214
+     *	@param		Translate	$outputlangs		Lang output object
215
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
216
+     *  @param		int			$hidedetails		Do not show line details
217
+     *  @param		int			$hidedesc			Do not show desc
218
+     *  @param		int			$hideref			Do not show ref
219
+     *	@return		int         					1 if OK, <=0 if KO
220
+     */
221
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
222
+    {
223 223
         // phpcs:enable
224
-		global $user, $langs, $conf, $mysoc, $hookmanager;
225
-
226
-		if (empty($srctemplatepath))
227
-		{
228
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
229
-			return -1;
230
-		}
231
-
232
-		// Add odtgeneration hook
233
-		if (! is_object($hookmanager))
234
-		{
235
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
236
-			$hookmanager=new HookManager($this->db);
237
-		}
238
-		$hookmanager->initHooks(array('odtgeneration'));
239
-		global $action;
240
-
241
-		if (! is_object($outputlangs)) $outputlangs=$langs;
242
-		$sav_charset_output=$outputlangs->charset_output;
243
-		$outputlangs->charset_output='UTF-8';
244
-
245
-		// Load translation files required by the page
246
-		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
247
-
248
-		if ($conf->user->dir_output)
249
-		{
250
-			// If $object is id instead of object
251
-			if (! is_object($object))
252
-			{
253
-				$id = $object;
254
-				$object = new UserGroup($this->db);
255
-				$result=$object->fetch($id);
256
-				if ($result < 0)
257
-				{
258
-					dol_print_error($this->db,$object->error);
259
-					return -1;
260
-				}
261
-			}
262
-
263
-			$dir = $conf->usergroup->dir_output;
264
-			$objectref = dol_sanitizeFileName($object->ref);
265
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
266
-			$file = $dir . "/" . $objectref . ".odt";
267
-
268
-			if (! file_exists($dir))
269
-			{
270
-				if (dol_mkdir($dir) < 0)
271
-				{
272
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
273
-					return -1;
274
-				}
275
-			}
276
-
277
-			if (file_exists($dir))
278
-			{
279
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
280
-				$newfile=basename($srctemplatepath);
281
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
282
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
283
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
284
-
285
-				$newfiletmp=$objectref.'_'.$newfiletmp;
286
-
287
-				// Get extension (ods or odt)
288
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
289
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
290
-				{
291
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
292
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
293
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
294
-				}
295
-				else
296
-				{
297
-					$filename=$newfiletmp.'.'.$newfileformat;
298
-				}
299
-				$file=$dir.'/'.$filename;
300
-				//print "newdir=".$dir;
301
-				//print "newfile=".$newfile;
302
-				//print "file=".$file;
303
-				//print "conf->user->dir_temp=".$conf->user->dir_temp;
304
-
305
-				dol_mkdir($conf->user->dir_temp);
306
-
307
-
308
-				// If CUSTOMER contact defined on user, we use it
309
-				$usecontact=false;
310
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
311
-				if (count($arrayidcontact) > 0)
312
-				{
313
-					$usecontact=true;
314
-					$result=$object->fetch_contact($arrayidcontact[0]);
315
-				}
316
-
317
-				// Recipient name
318
-				if (! empty($usecontact))
319
-				{
320
-					// On peut utiliser le nom de la societe du contact
321
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
322
-					else {
323
-                        			$socobject = $object->thirdparty;
324
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
325
-                        			$contactobject = $object->contact;
326
-                    			}
327
-				}
328
-				else
329
-				{
330
-					$socobject=$object->thirdparty;
331
-				}
332
-				// Make substitution
333
-				$substitutionarray=array(
334
-				'__FROM_NAME__' => $this->emetteur->name,
335
-				'__FROM_EMAIL__' => $this->emetteur->email,
336
-				'__TOTAL_TTC__' => $object->total_ttc,
337
-				'__TOTAL_HT__' => $object->total_ht,
338
-				'__TOTAL_VAT__' => $object->total_vat
339
-				);
340
-				complete_substitutions_array($substitutionarray, $langs, $object);
341
-				// Call the ODTSubstitution hook
342
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
343
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
344
-
345
-				// Line of free text
346
-				$newfreetext='';
347
-				$paramfreetext='user_FREE_TEXT';
348
-				if (! empty($conf->global->$paramfreetext))
349
-				{
350
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
351
-				}
352
-
353
-				// Open and load template
354
-				require_once ODTPHP_PATH.'odf.php';
355
-				try {
356
-					$odfHandler = new odf(
357
-						$srctemplatepath,
358
-						array(
359
-							'PATH_TO_TMP'	  => $conf->user->dir_temp,
360
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
361
-							'DELIMITER_LEFT'  => '{',
362
-							'DELIMITER_RIGHT' => '}'
363
-						)
364
-					);
365
-				} catch (Exception $e) {
366
-					$this->error=$e->getMessage();
367
-					dol_syslog($e->getMessage(), LOG_WARNING);
368
-					return -1;
369
-				}
370
-				// After construction $odfHandler->contentXml contains content and
371
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
372
-				// [!-- BEGIN lines --]*[!-- END lines --]
373
-				//print html_entity_decode($odfHandler->__toString());
374
-				//print exit;
375
-
376
-
377
-				// Make substitutions into odt of freetext
378
-				try {
379
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
380
-				}
381
-				catch (OdfException $e)
382
-				{
383
-					dol_syslog($e->getMessage(), LOG_WARNING);
384
-				}
385
-
386
-				// Make substitutions into odt
387
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
388
-				$array_global=$this->get_substitutionarray_each_var_object($object,$outputlangs);
389
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
390
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
391
-				$array_objet=$this->get_substitutionarray_each_var_object($object,$outputlangs);
392
-				$array_other=$this->get_substitutionarray_other($outputlangs);
393
-				// retrieve contact information for use in object as contact_xxx tags
394
-				$array_thirdparty_contact = array();
395
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
396
-
397
-				$tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
398
-				complete_substitutions_array($tmparray, $outputlangs, $object);
399
-				$object->fetch_optionals();
400
-				// Call the ODTSubstitution hook
401
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
402
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
403
-				foreach($tmparray as $key=>$value)
404
-				{
405
-					try
406
-					{
407
-						if (preg_match('/logo$/',$key)) // Image
408
-						{
409
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
410
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
411
-						}
412
-						else    // Text
413
-						{
414
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
415
-						}
416
-					}
417
-					catch (OdfException $e)
418
-					{
419
-						dol_syslog($e->getMessage(), LOG_WARNING);
420
-					}
421
-				}
422
-				// Replace tags of lines
423
-				try
424
-				{
425
-					$foundtagforlines = 1;
426
-					try {
427
-						$listlines = $odfHandler->setSegment('lines');
428
-					}
429
-					catch (OdfException $e)
430
-					{
431
-						// We may arrive here if tags for lines not present into template
432
-						$foundtagforlines = 0;
433
-						dol_syslog($e->getMessage(), LOG_INFO);
434
-					}
435
-					if ($foundtagforlines)
436
-					{
437
-						foreach ($object->members as $u)
438
-						{
439
-							$tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
440
-							unset($tmparray['object_pass']);
441
-							unset($tmparray['object_pass_indatabase']);
442
-							complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
443
-							// Call the ODTSubstitutionLine hook
444
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$u);
445
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
446
-							foreach($tmparray as $key => $val)
447
-							{
448
-								try
449
-								{
450
-									if (!is_array($val)) {
451
-										$listlines->setVars($key, $val, true, 'UTF-8');
452
-									}
453
-								}
454
-								catch (OdfException $e)
455
-								{
456
-									dol_syslog($e->getMessage(), LOG_WARNING);
457
-								}
458
-								catch (SegmentException $e)
459
-								{
460
-									dol_syslog($e->getMessage(), LOG_WARNING);
461
-								}
462
-							}
463
-							$listlines->merge();
464
-						}
465
-						$odfHandler->mergeSegment($listlines);
466
-					}
467
-				}
468
-				catch(OdfException $e)
469
-				{
470
-					$this->error=$e->getMessage();
471
-					dol_syslog($this->error, LOG_WARNING);
472
-					return -1;
473
-				}
474
-
475
-				// Replace labels translated
476
-				$tmparray=$outputlangs->get_translations_for_substitutions();
477
-				foreach($tmparray as $key => $value)
478
-				{
479
-					try {
480
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
481
-					}
482
-					catch (OdfException $e)
483
-					{
484
-						dol_syslog($e->getMessage(), LOG_WARNING);
485
-					}
486
-				}
487
-
488
-				// Call the beforeODTSave hook
489
-				$parameters=array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
490
-				$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
491
-
492
-				// Write new file
493
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
494
-					try {
495
-						$odfHandler->exportAsAttachedPDF($file);
496
-					} catch (Exception $e) {
497
-						$this->error=$e->getMessage();
498
-						dol_syslog($e->getMessage(), LOG_WARNING);
499
-						return -1;
500
-					}
501
-				}
502
-				else {
503
-					try {
504
-						$odfHandler->saveToDisk($file);
505
-					} catch (Exception $e) {
506
-						$this->error=$e->getMessage();
507
-						dol_syslog($e->getMessage(), LOG_WARNING);
508
-						return -1;
509
-					}
510
-				}
511
-
512
-				$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
513
-
514
-				if (! empty($conf->global->MAIN_UMASK))
515
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
516
-
517
-				$odfHandler=null;	// Destroy object
518
-
519
-				$this->result = array('fullpath'=>$file);
520
-
521
-				return 1;   // Success
522
-			}
523
-			else
524
-			{
525
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526
-				return -1;
527
-			}
528
-		}
529
-
530
-		return -1;
531
-	}
224
+        global $user, $langs, $conf, $mysoc, $hookmanager;
225
+
226
+        if (empty($srctemplatepath))
227
+        {
228
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
229
+            return -1;
230
+        }
231
+
232
+        // Add odtgeneration hook
233
+        if (! is_object($hookmanager))
234
+        {
235
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
236
+            $hookmanager=new HookManager($this->db);
237
+        }
238
+        $hookmanager->initHooks(array('odtgeneration'));
239
+        global $action;
240
+
241
+        if (! is_object($outputlangs)) $outputlangs=$langs;
242
+        $sav_charset_output=$outputlangs->charset_output;
243
+        $outputlangs->charset_output='UTF-8';
244
+
245
+        // Load translation files required by the page
246
+        $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
247
+
248
+        if ($conf->user->dir_output)
249
+        {
250
+            // If $object is id instead of object
251
+            if (! is_object($object))
252
+            {
253
+                $id = $object;
254
+                $object = new UserGroup($this->db);
255
+                $result=$object->fetch($id);
256
+                if ($result < 0)
257
+                {
258
+                    dol_print_error($this->db,$object->error);
259
+                    return -1;
260
+                }
261
+            }
262
+
263
+            $dir = $conf->usergroup->dir_output;
264
+            $objectref = dol_sanitizeFileName($object->ref);
265
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
266
+            $file = $dir . "/" . $objectref . ".odt";
267
+
268
+            if (! file_exists($dir))
269
+            {
270
+                if (dol_mkdir($dir) < 0)
271
+                {
272
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
273
+                    return -1;
274
+                }
275
+            }
276
+
277
+            if (file_exists($dir))
278
+            {
279
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
280
+                $newfile=basename($srctemplatepath);
281
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
282
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
283
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
284
+
285
+                $newfiletmp=$objectref.'_'.$newfiletmp;
286
+
287
+                // Get extension (ods or odt)
288
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
289
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
290
+                {
291
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
292
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
293
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
294
+                }
295
+                else
296
+                {
297
+                    $filename=$newfiletmp.'.'.$newfileformat;
298
+                }
299
+                $file=$dir.'/'.$filename;
300
+                //print "newdir=".$dir;
301
+                //print "newfile=".$newfile;
302
+                //print "file=".$file;
303
+                //print "conf->user->dir_temp=".$conf->user->dir_temp;
304
+
305
+                dol_mkdir($conf->user->dir_temp);
306
+
307
+
308
+                // If CUSTOMER contact defined on user, we use it
309
+                $usecontact=false;
310
+                $arrayidcontact=$object->getIdContact('external','CUSTOMER');
311
+                if (count($arrayidcontact) > 0)
312
+                {
313
+                    $usecontact=true;
314
+                    $result=$object->fetch_contact($arrayidcontact[0]);
315
+                }
316
+
317
+                // Recipient name
318
+                if (! empty($usecontact))
319
+                {
320
+                    // On peut utiliser le nom de la societe du contact
321
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
322
+                    else {
323
+                                    $socobject = $object->thirdparty;
324
+                                    // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
325
+                                    $contactobject = $object->contact;
326
+                                }
327
+                }
328
+                else
329
+                {
330
+                    $socobject=$object->thirdparty;
331
+                }
332
+                // Make substitution
333
+                $substitutionarray=array(
334
+                '__FROM_NAME__' => $this->emetteur->name,
335
+                '__FROM_EMAIL__' => $this->emetteur->email,
336
+                '__TOTAL_TTC__' => $object->total_ttc,
337
+                '__TOTAL_HT__' => $object->total_ht,
338
+                '__TOTAL_VAT__' => $object->total_vat
339
+                );
340
+                complete_substitutions_array($substitutionarray, $langs, $object);
341
+                // Call the ODTSubstitution hook
342
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
343
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
344
+
345
+                // Line of free text
346
+                $newfreetext='';
347
+                $paramfreetext='user_FREE_TEXT';
348
+                if (! empty($conf->global->$paramfreetext))
349
+                {
350
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
351
+                }
352
+
353
+                // Open and load template
354
+                require_once ODTPHP_PATH.'odf.php';
355
+                try {
356
+                    $odfHandler = new odf(
357
+                        $srctemplatepath,
358
+                        array(
359
+                            'PATH_TO_TMP'	  => $conf->user->dir_temp,
360
+                            'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
361
+                            'DELIMITER_LEFT'  => '{',
362
+                            'DELIMITER_RIGHT' => '}'
363
+                        )
364
+                    );
365
+                } catch (Exception $e) {
366
+                    $this->error=$e->getMessage();
367
+                    dol_syslog($e->getMessage(), LOG_WARNING);
368
+                    return -1;
369
+                }
370
+                // After construction $odfHandler->contentXml contains content and
371
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
372
+                // [!-- BEGIN lines --]*[!-- END lines --]
373
+                //print html_entity_decode($odfHandler->__toString());
374
+                //print exit;
375
+
376
+
377
+                // Make substitutions into odt of freetext
378
+                try {
379
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
380
+                }
381
+                catch (OdfException $e)
382
+                {
383
+                    dol_syslog($e->getMessage(), LOG_WARNING);
384
+                }
385
+
386
+                // Make substitutions into odt
387
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
388
+                $array_global=$this->get_substitutionarray_each_var_object($object,$outputlangs);
389
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
390
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
391
+                $array_objet=$this->get_substitutionarray_each_var_object($object,$outputlangs);
392
+                $array_other=$this->get_substitutionarray_other($outputlangs);
393
+                // retrieve contact information for use in object as contact_xxx tags
394
+                $array_thirdparty_contact = array();
395
+                if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
396
+
397
+                $tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
398
+                complete_substitutions_array($tmparray, $outputlangs, $object);
399
+                $object->fetch_optionals();
400
+                // Call the ODTSubstitution hook
401
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
402
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
403
+                foreach($tmparray as $key=>$value)
404
+                {
405
+                    try
406
+                    {
407
+                        if (preg_match('/logo$/',$key)) // Image
408
+                        {
409
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
410
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
411
+                        }
412
+                        else    // Text
413
+                        {
414
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
415
+                        }
416
+                    }
417
+                    catch (OdfException $e)
418
+                    {
419
+                        dol_syslog($e->getMessage(), LOG_WARNING);
420
+                    }
421
+                }
422
+                // Replace tags of lines
423
+                try
424
+                {
425
+                    $foundtagforlines = 1;
426
+                    try {
427
+                        $listlines = $odfHandler->setSegment('lines');
428
+                    }
429
+                    catch (OdfException $e)
430
+                    {
431
+                        // We may arrive here if tags for lines not present into template
432
+                        $foundtagforlines = 0;
433
+                        dol_syslog($e->getMessage(), LOG_INFO);
434
+                    }
435
+                    if ($foundtagforlines)
436
+                    {
437
+                        foreach ($object->members as $u)
438
+                        {
439
+                            $tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
440
+                            unset($tmparray['object_pass']);
441
+                            unset($tmparray['object_pass_indatabase']);
442
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
443
+                            // Call the ODTSubstitutionLine hook
444
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$u);
445
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
446
+                            foreach($tmparray as $key => $val)
447
+                            {
448
+                                try
449
+                                {
450
+                                    if (!is_array($val)) {
451
+                                        $listlines->setVars($key, $val, true, 'UTF-8');
452
+                                    }
453
+                                }
454
+                                catch (OdfException $e)
455
+                                {
456
+                                    dol_syslog($e->getMessage(), LOG_WARNING);
457
+                                }
458
+                                catch (SegmentException $e)
459
+                                {
460
+                                    dol_syslog($e->getMessage(), LOG_WARNING);
461
+                                }
462
+                            }
463
+                            $listlines->merge();
464
+                        }
465
+                        $odfHandler->mergeSegment($listlines);
466
+                    }
467
+                }
468
+                catch(OdfException $e)
469
+                {
470
+                    $this->error=$e->getMessage();
471
+                    dol_syslog($this->error, LOG_WARNING);
472
+                    return -1;
473
+                }
474
+
475
+                // Replace labels translated
476
+                $tmparray=$outputlangs->get_translations_for_substitutions();
477
+                foreach($tmparray as $key => $value)
478
+                {
479
+                    try {
480
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
481
+                    }
482
+                    catch (OdfException $e)
483
+                    {
484
+                        dol_syslog($e->getMessage(), LOG_WARNING);
485
+                    }
486
+                }
487
+
488
+                // Call the beforeODTSave hook
489
+                $parameters=array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
490
+                $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
491
+
492
+                // Write new file
493
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
494
+                    try {
495
+                        $odfHandler->exportAsAttachedPDF($file);
496
+                    } catch (Exception $e) {
497
+                        $this->error=$e->getMessage();
498
+                        dol_syslog($e->getMessage(), LOG_WARNING);
499
+                        return -1;
500
+                    }
501
+                }
502
+                else {
503
+                    try {
504
+                        $odfHandler->saveToDisk($file);
505
+                    } catch (Exception $e) {
506
+                        $this->error=$e->getMessage();
507
+                        dol_syslog($e->getMessage(), LOG_WARNING);
508
+                        return -1;
509
+                    }
510
+                }
511
+
512
+                $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
513
+
514
+                if (! empty($conf->global->MAIN_UMASK))
515
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
516
+
517
+                $odfHandler=null;	// Destroy object
518
+
519
+                $this->result = array('fullpath'=>$file);
520
+
521
+                return 1;   // Success
522
+            }
523
+            else
524
+            {
525
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526
+                return -1;
527
+            }
528
+        }
529
+
530
+        return -1;
531
+    }
532 532
 }
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 		global $conf, $langs, $mysoc;
68 68
 
69 69
 		// Load translation files required by the page
70
-    $langs->loadLangs(array("main","companies"));
70
+    $langs->loadLangs(array("main", "companies"));
71 71
 
72 72
 		$this->db = $db;
73 73
 		$this->name = "ODT templates";
74 74
 		$this->description = $langs->trans("DocumentModelOdt");
75
-		$this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
75
+		$this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
76 76
 
77 77
 		// Dimension page pour format A4
78 78
 		$this->type = 'odt';
79 79
 		$this->page_largeur = 0;
80 80
 		$this->page_hauteur = 0;
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=0;
83
-		$this->marge_droite=0;
84
-		$this->marge_haute=0;
85
-		$this->marge_basse=0;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 0;                     // Gere option tva USERGROUP_TVAOPTION
89
-		$this->option_modereg = 0;                 // Affiche mode reglement
90
-		$this->option_condreg = 0;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 0;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
81
+		$this->format = array($this->page_largeur, $this->page_hauteur);
82
+		$this->marge_gauche = 0;
83
+		$this->marge_droite = 0;
84
+		$this->marge_haute = 0;
85
+		$this->marge_basse = 0;
86
+
87
+		$this->option_logo = 1; // Affiche logo
88
+		$this->option_tva = 0; // Gere option tva USERGROUP_TVAOPTION
89
+		$this->option_modereg = 0; // Affiche mode reglement
90
+		$this->option_condreg = 0; // Affiche conditions reglement
91
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
92
+		$this->option_multilang = 1; // Dispo en plusieurs langues
93
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
94
+		$this->option_credit_note = 0; // Support credit notes
95
+		$this->option_freetext = 1; // Support add of a personalised text
96
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
97 97
 
98 98
 		// Recupere emetteur
99
-		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
99
+		$this->emetteur = $mysoc;
100
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
101 101
 	}
102 102
 
103 103
 
@@ -109,99 +109,99 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	function info($langs)
111 111
 	{
112
-		global $conf,$langs;
112
+		global $conf, $langs;
113 113
 
114 114
 		// Load translation files required by the page
115
-        $langs->loadLangs(array("errors","companies"));
115
+        $langs->loadLangs(array("errors", "companies"));
116 116
 
117 117
 		$form = new Form($this->db);
118 118
 
119 119
 		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
-		$texte.= '<input type="hidden" name="param1" value="USERGROUP_ADDON_PDF_ODT_PATH">';
120
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
123
+		$texte .= '<input type="hidden" name="param1" value="USERGROUP_ADDON_PDF_ODT_PATH">';
124 124
 		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
125 125
 		{
126
-			$texte.= '<input type="hidden" name="param2" value="USERGROUP_ADDON_PDF_ODT_DEFAULT">';
127
-			$texte.= '<input type="hidden" name="param3" value="USERGROUP_ADDON_PDF_ODT_TOBILL">';
128
-			$texte.= '<input type="hidden" name="param4" value="USERGROUP_ADDON_PDF_ODT_CLOSED">';
126
+			$texte .= '<input type="hidden" name="param2" value="USERGROUP_ADDON_PDF_ODT_DEFAULT">';
127
+			$texte .= '<input type="hidden" name="param3" value="USERGROUP_ADDON_PDF_ODT_TOBILL">';
128
+			$texte .= '<input type="hidden" name="param4" value="USERGROUP_ADDON_PDF_ODT_CLOSED">';
129 129
 		}
130
-		$texte.= '<table class="nobordernopadding" width="100%">';
130
+		$texte .= '<table class="nobordernopadding" width="100%">';
131 131
 
132 132
 		// List of directories area
133
-		$texte.= '<tr><td>';
134
-		$texttitle=$langs->trans("ListOfDirectories");
135
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH)));
136
-		$listoffiles=array();
137
-		foreach($listofdir as $key=>$tmpdir)
133
+		$texte .= '<tr><td>';
134
+		$texttitle = $langs->trans("ListOfDirectories");
135
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH)));
136
+		$listoffiles = array();
137
+		foreach ($listofdir as $key=>$tmpdir)
138 138
 		{
139
-			$tmpdir=trim($tmpdir);
140
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
-			if (! $tmpdir) {
139
+			$tmpdir = trim($tmpdir);
140
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
141
+			if (!$tmpdir) {
142 142
 				unset($listofdir[$key]); continue;
143 143
 			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
145 145
 			else
146 146
 			{
147
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
147
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
148
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
149 149
 			}
150 150
 		}
151
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
151
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
152 152
 		// Add list of substitution keys
153
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
-
156
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
159
-		$texte.=$conf->global->USERGROUP_ADDON_PDF_ODT_PATH;
160
-		$texte.= '</textarea>';
161
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
-		$texte.= '<br></div></div>';
153
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
155
+
156
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
157
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
159
+		$texte .= $conf->global->USERGROUP_ADDON_PDF_ODT_PATH;
160
+		$texte .= '</textarea>';
161
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
162
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
+		$texte .= '<br></div></div>';
164 164
 
165 165
 		// Scan directories
166 166
 		if (count($listofdir))
167 167
 		{
168
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
168
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
169 169
 
170 170
 			if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
171 171
 			{
172 172
 				// Model for creation
173
-				$liste=ModelePDFUserGroup::liste_modeles($this->db);
174
-				$texte.= '<table width="50%;">';
175
-				$texte.= '<tr>';
176
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
177
-				$texte.= '<td colspan="">';
178
-				$texte.= $form->selectarray('value2',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT);
179
-				$texte.= "</td></tr>";
180
-
181
-				$texte.= '<tr>';
182
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
183
-				$texte.= '<td colspan="">';
184
-				$texte.= $form->selectarray('value3',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL);
185
-				$texte.= "</td></tr>";
186
-				$texte.= '<tr>';
187
-
188
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
189
-				$texte.= '<td colspan="">';
190
-				$texte.= $form->selectarray('value4',$liste,$conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED);
191
-				$texte.= "</td></tr>";
192
-				$texte.= '</table>';
173
+				$liste = ModelePDFUserGroup::liste_modeles($this->db);
174
+				$texte .= '<table width="50%;">';
175
+				$texte .= '<tr>';
176
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
177
+				$texte .= '<td colspan="">';
178
+				$texte .= $form->selectarray('value2', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT);
179
+				$texte .= "</td></tr>";
180
+
181
+				$texte .= '<tr>';
182
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
183
+				$texte .= '<td colspan="">';
184
+				$texte .= $form->selectarray('value3', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL);
185
+				$texte .= "</td></tr>";
186
+				$texte .= '<tr>';
187
+
188
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
189
+				$texte .= '<td colspan="">';
190
+				$texte .= $form->selectarray('value4', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED);
191
+				$texte .= "</td></tr>";
192
+				$texte .= '</table>';
193 193
 			}
194 194
 		}
195 195
 
196
-		$texte.= '</td>';
196
+		$texte .= '</td>';
197 197
 
198
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
199
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
200
-		$texte.= '</td>';
201
-		$texte.= '</tr>';
198
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
199
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
200
+		$texte .= '</td>';
201
+		$texte .= '</tr>';
202 202
 
203
-		$texte.= '</table>';
204
-		$texte.= '</form>';
203
+		$texte .= '</table>';
204
+		$texte .= '</form>';
205 205
 
206 206
 		return $texte;
207 207
 	}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 *  @param		int			$hideref			Do not show ref
219 219
 	 *	@return		int         					1 if OK, <=0 if KO
220 220
 	 */
221
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
221
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
222 222
 	{
223 223
         // phpcs:enable
224 224
 		global $user, $langs, $conf, $mysoc, $hookmanager;
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		}
231 231
 
232 232
 		// Add odtgeneration hook
233
-		if (! is_object($hookmanager))
233
+		if (!is_object($hookmanager))
234 234
 		{
235 235
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
236
-			$hookmanager=new HookManager($this->db);
236
+			$hookmanager = new HookManager($this->db);
237 237
 		}
238 238
 		$hookmanager->initHooks(array('odtgeneration'));
239 239
 		global $action;
240 240
 
241
-		if (! is_object($outputlangs)) $outputlangs=$langs;
242
-		$sav_charset_output=$outputlangs->charset_output;
243
-		$outputlangs->charset_output='UTF-8';
241
+		if (!is_object($outputlangs)) $outputlangs = $langs;
242
+		$sav_charset_output = $outputlangs->charset_output;
243
+		$outputlangs->charset_output = 'UTF-8';
244 244
 
245 245
 		// Load translation files required by the page
246 246
 		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
@@ -248,28 +248,28 @@  discard block
 block discarded – undo
248 248
 		if ($conf->user->dir_output)
249 249
 		{
250 250
 			// If $object is id instead of object
251
-			if (! is_object($object))
251
+			if (!is_object($object))
252 252
 			{
253 253
 				$id = $object;
254 254
 				$object = new UserGroup($this->db);
255
-				$result=$object->fetch($id);
255
+				$result = $object->fetch($id);
256 256
 				if ($result < 0)
257 257
 				{
258
-					dol_print_error($this->db,$object->error);
258
+					dol_print_error($this->db, $object->error);
259 259
 					return -1;
260 260
 				}
261 261
 			}
262 262
 
263 263
 			$dir = $conf->usergroup->dir_output;
264 264
 			$objectref = dol_sanitizeFileName($object->ref);
265
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
266
-			$file = $dir . "/" . $objectref . ".odt";
265
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
266
+			$file = $dir."/".$objectref.".odt";
267 267
 
268
-			if (! file_exists($dir))
268
+			if (!file_exists($dir))
269 269
 			{
270 270
 				if (dol_mkdir($dir) < 0)
271 271
 				{
272
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
272
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
273 273
 					return -1;
274 274
 				}
275 275
 			}
@@ -277,26 +277,26 @@  discard block
 block discarded – undo
277 277
 			if (file_exists($dir))
278 278
 			{
279 279
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
280
-				$newfile=basename($srctemplatepath);
281
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
282
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
283
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
280
+				$newfile = basename($srctemplatepath);
281
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
282
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
283
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
284 284
 
285
-				$newfiletmp=$objectref.'_'.$newfiletmp;
285
+				$newfiletmp = $objectref.'_'.$newfiletmp;
286 286
 
287 287
 				// Get extension (ods or odt)
288
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
289
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
288
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
289
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
290 290
 				{
291
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
292
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
293
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
291
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
292
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
293
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
294 294
 				}
295 295
 				else
296 296
 				{
297
-					$filename=$newfiletmp.'.'.$newfileformat;
297
+					$filename = $newfiletmp.'.'.$newfileformat;
298 298
 				}
299
-				$file=$dir.'/'.$filename;
299
+				$file = $dir.'/'.$filename;
300 300
 				//print "newdir=".$dir;
301 301
 				//print "newfile=".$newfile;
302 302
 				//print "file=".$file;
@@ -306,19 +306,19 @@  discard block
 block discarded – undo
306 306
 
307 307
 
308 308
 				// If CUSTOMER contact defined on user, we use it
309
-				$usecontact=false;
310
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
309
+				$usecontact = false;
310
+				$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
311 311
 				if (count($arrayidcontact) > 0)
312 312
 				{
313
-					$usecontact=true;
314
-					$result=$object->fetch_contact($arrayidcontact[0]);
313
+					$usecontact = true;
314
+					$result = $object->fetch_contact($arrayidcontact[0]);
315 315
 				}
316 316
 
317 317
 				// Recipient name
318
-				if (! empty($usecontact))
318
+				if (!empty($usecontact))
319 319
 				{
320 320
 					// On peut utiliser le nom de la societe du contact
321
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
321
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
322 322
 					else {
323 323
                         			$socobject = $object->thirdparty;
324 324
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 				}
328 328
 				else
329 329
 				{
330
-					$socobject=$object->thirdparty;
330
+					$socobject = $object->thirdparty;
331 331
 				}
332 332
 				// Make substitution
333
-				$substitutionarray=array(
333
+				$substitutionarray = array(
334 334
 				'__FROM_NAME__' => $this->emetteur->name,
335 335
 				'__FROM_EMAIL__' => $this->emetteur->email,
336 336
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 				);
340 340
 				complete_substitutions_array($substitutionarray, $langs, $object);
341 341
 				// Call the ODTSubstitution hook
342
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
343
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
342
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
343
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
344 344
 
345 345
 				// Line of free text
346
-				$newfreetext='';
347
-				$paramfreetext='user_FREE_TEXT';
348
-				if (! empty($conf->global->$paramfreetext))
346
+				$newfreetext = '';
347
+				$paramfreetext = 'user_FREE_TEXT';
348
+				if (!empty($conf->global->$paramfreetext))
349 349
 				{
350
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
350
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
351 351
 				}
352 352
 
353 353
 				// Open and load template
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
 						$srctemplatepath,
358 358
 						array(
359 359
 							'PATH_TO_TMP'	  => $conf->user->dir_temp,
360
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
360
+							'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
361 361
 							'DELIMITER_LEFT'  => '{',
362 362
 							'DELIMITER_RIGHT' => '}'
363 363
 						)
364 364
 					);
365 365
 				} catch (Exception $e) {
366
-					$this->error=$e->getMessage();
366
+					$this->error = $e->getMessage();
367 367
 					dol_syslog($e->getMessage(), LOG_WARNING);
368 368
 					return -1;
369 369
 				}
@@ -384,27 +384,27 @@  discard block
 block discarded – undo
384 384
 				}
385 385
 
386 386
 				// Make substitutions into odt
387
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
388
-				$array_global=$this->get_substitutionarray_each_var_object($object,$outputlangs);
389
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
390
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
391
-				$array_objet=$this->get_substitutionarray_each_var_object($object,$outputlangs);
392
-				$array_other=$this->get_substitutionarray_other($outputlangs);
387
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
388
+				$array_global = $this->get_substitutionarray_each_var_object($object, $outputlangs);
389
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
390
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
391
+				$array_objet = $this->get_substitutionarray_each_var_object($object, $outputlangs);
392
+				$array_other = $this->get_substitutionarray_other($outputlangs);
393 393
 				// retrieve contact information for use in object as contact_xxx tags
394 394
 				$array_thirdparty_contact = array();
395
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
395
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
396 396
 
397
-				$tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
397
+				$tmparray = array_merge($array_global, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
398 398
 				complete_substitutions_array($tmparray, $outputlangs, $object);
399 399
 				$object->fetch_optionals();
400 400
 				// Call the ODTSubstitution hook
401
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
402
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
403
-				foreach($tmparray as $key=>$value)
401
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
402
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
403
+				foreach ($tmparray as $key=>$value)
404 404
 				{
405 405
 					try
406 406
 					{
407
-						if (preg_match('/logo$/',$key)) // Image
407
+						if (preg_match('/logo$/', $key)) // Image
408 408
 						{
409 409
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
410 410
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -436,14 +436,14 @@  discard block
 block discarded – undo
436 436
 					{
437 437
 						foreach ($object->members as $u)
438 438
 						{
439
-							$tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
439
+							$tmparray = $this->get_substitutionarray_each_var_object($u, $outputlangs);
440 440
 							unset($tmparray['object_pass']);
441 441
 							unset($tmparray['object_pass_indatabase']);
442 442
 							complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
443 443
 							// Call the ODTSubstitutionLine hook
444
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$u);
445
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
446
-							foreach($tmparray as $key => $val)
444
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$u);
445
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
446
+							foreach ($tmparray as $key => $val)
447 447
 							{
448 448
 								try
449 449
 								{
@@ -465,16 +465,16 @@  discard block
 block discarded – undo
465 465
 						$odfHandler->mergeSegment($listlines);
466 466
 					}
467 467
 				}
468
-				catch(OdfException $e)
468
+				catch (OdfException $e)
469 469
 				{
470
-					$this->error=$e->getMessage();
470
+					$this->error = $e->getMessage();
471 471
 					dol_syslog($this->error, LOG_WARNING);
472 472
 					return -1;
473 473
 				}
474 474
 
475 475
 				// Replace labels translated
476
-				$tmparray=$outputlangs->get_translations_for_substitutions();
477
-				foreach($tmparray as $key => $value)
476
+				$tmparray = $outputlangs->get_translations_for_substitutions();
477
+				foreach ($tmparray as $key => $value)
478 478
 				{
479 479
 					try {
480 480
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
 				}
487 487
 
488 488
 				// Call the beforeODTSave hook
489
-				$parameters=array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
490
-				$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
489
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
490
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
491 491
 
492 492
 				// Write new file
493 493
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
494 494
 					try {
495 495
 						$odfHandler->exportAsAttachedPDF($file);
496 496
 					} catch (Exception $e) {
497
-						$this->error=$e->getMessage();
497
+						$this->error = $e->getMessage();
498 498
 						dol_syslog($e->getMessage(), LOG_WARNING);
499 499
 						return -1;
500 500
 					}
@@ -503,26 +503,26 @@  discard block
 block discarded – undo
503 503
 					try {
504 504
 						$odfHandler->saveToDisk($file);
505 505
 					} catch (Exception $e) {
506
-						$this->error=$e->getMessage();
506
+						$this->error = $e->getMessage();
507 507
 						dol_syslog($e->getMessage(), LOG_WARNING);
508 508
 						return -1;
509 509
 					}
510 510
 				}
511 511
 
512
-				$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
512
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
513 513
 
514
-				if (! empty($conf->global->MAIN_UMASK))
514
+				if (!empty($conf->global->MAIN_UMASK))
515 515
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
516 516
 
517
-				$odfHandler=null;	// Destroy object
517
+				$odfHandler = null; // Destroy object
518 518
 
519 519
 				$this->result = array('fullpath'=>$file);
520 520
 
521
-				return 1;   // Success
521
+				return 1; // Success
522 522
 			}
523 523
 			else
524 524
 			{
525
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
525
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
526 526
 				return -1;
527 527
 			}
528 528
 		}
Please login to merge, or discard this patch.
Braces   +45 added lines, -38 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 
98 98
 		// Recupere emetteur
99 99
 		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
100
+		if (! $this->emetteur->country_code) {
101
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
102
+		}
103
+		// By default if not defined
101 104
 	}
102 105
 
103 106
 
@@ -141,11 +144,14 @@  discard block
 block discarded – undo
141 144
 			if (! $tmpdir) {
142 145
 				unset($listofdir[$key]); continue;
143 146
 			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
-			else
147
+			if (! is_dir($tmpdir)) {
148
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
149
+			} else
146 150
 			{
147 151
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
152
+				if (count($tmpfiles)) {
153
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
154
+				}
149 155
 			}
150 156
 		}
151 157
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -238,7 +244,9 @@  discard block
 block discarded – undo
238 244
 		$hookmanager->initHooks(array('odtgeneration'));
239 245
 		global $action;
240 246
 
241
-		if (! is_object($outputlangs)) $outputlangs=$langs;
247
+		if (! is_object($outputlangs)) {
248
+		    $outputlangs=$langs;
249
+		}
242 250
 		$sav_charset_output=$outputlangs->charset_output;
243 251
 		$outputlangs->charset_output='UTF-8';
244 252
 
@@ -262,7 +270,9 @@  discard block
 block discarded – undo
262 270
 
263 271
 			$dir = $conf->usergroup->dir_output;
264 272
 			$objectref = dol_sanitizeFileName($object->ref);
265
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
273
+			if (! preg_match('/specimen/i',$objectref)) {
274
+			    $dir.= "/" . $objectref;
275
+			}
266 276
 			$file = $dir . "/" . $objectref . ".odt";
267 277
 
268 278
 			if (! file_exists($dir))
@@ -289,10 +299,11 @@  discard block
 block discarded – undo
289 299
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
290 300
 				{
291 301
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
292
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
302
+				    if ($format == '1') {
303
+				        $format='%Y%m%d%H%M%S';
304
+				    }
293 305
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
294
-				}
295
-				else
306
+				} else
296 307
 				{
297 308
 					$filename=$newfiletmp.'.'.$newfileformat;
298 309
 				}
@@ -318,14 +329,14 @@  discard block
 block discarded – undo
318 329
 				if (! empty($usecontact))
319 330
 				{
320 331
 					// On peut utiliser le nom de la societe du contact
321
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
322
-					else {
332
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
333
+					    $socobject = $object->contact;
334
+					} else {
323 335
                         			$socobject = $object->thirdparty;
324 336
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
325 337
                         			$contactobject = $object->contact;
326 338
                     			}
327
-				}
328
-				else
339
+				} else
329 340
 				{
330 341
 					$socobject=$object->thirdparty;
331 342
 				}
@@ -377,8 +388,7 @@  discard block
 block discarded – undo
377 388
 				// Make substitutions into odt of freetext
378 389
 				try {
379 390
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
380
-				}
381
-				catch (OdfException $e)
391
+				} catch (OdfException $e)
382 392
 				{
383 393
 					dol_syslog($e->getMessage(), LOG_WARNING);
384 394
 				}
@@ -392,7 +402,9 @@  discard block
 block discarded – undo
392 402
 				$array_other=$this->get_substitutionarray_other($outputlangs);
393 403
 				// retrieve contact information for use in object as contact_xxx tags
394 404
 				$array_thirdparty_contact = array();
395
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
405
+				if ($usecontact && is_object($contactobject)) {
406
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
407
+				}
396 408
 
397 409
 				$tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
398 410
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -404,17 +416,18 @@  discard block
 block discarded – undo
404 416
 				{
405 417
 					try
406 418
 					{
407
-						if (preg_match('/logo$/',$key)) // Image
419
+						if (preg_match('/logo$/',$key)) {
420
+						    // Image
408 421
 						{
409 422
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
410
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
411
-						}
412
-						else    // Text
423
+						} else {
424
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
+							}
426
+						} else    // Text
413 427
 						{
414 428
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
415 429
 						}
416
-					}
417
-					catch (OdfException $e)
430
+					} catch (OdfException $e)
418 431
 					{
419 432
 						dol_syslog($e->getMessage(), LOG_WARNING);
420 433
 					}
@@ -425,8 +438,7 @@  discard block
 block discarded – undo
425 438
 					$foundtagforlines = 1;
426 439
 					try {
427 440
 						$listlines = $odfHandler->setSegment('lines');
428
-					}
429
-					catch (OdfException $e)
441
+					} catch (OdfException $e)
430 442
 					{
431 443
 						// We may arrive here if tags for lines not present into template
432 444
 						$foundtagforlines = 0;
@@ -450,12 +462,10 @@  discard block
 block discarded – undo
450 462
 									if (!is_array($val)) {
451 463
 										$listlines->setVars($key, $val, true, 'UTF-8');
452 464
 									}
453
-								}
454
-								catch (OdfException $e)
465
+								} catch (OdfException $e)
455 466
 								{
456 467
 									dol_syslog($e->getMessage(), LOG_WARNING);
457
-								}
458
-								catch (SegmentException $e)
468
+								} catch (SegmentException $e)
459 469
 								{
460 470
 									dol_syslog($e->getMessage(), LOG_WARNING);
461 471
 								}
@@ -464,8 +474,7 @@  discard block
 block discarded – undo
464 474
 						}
465 475
 						$odfHandler->mergeSegment($listlines);
466 476
 					}
467
-				}
468
-				catch(OdfException $e)
477
+				} catch(OdfException $e)
469 478
 				{
470 479
 					$this->error=$e->getMessage();
471 480
 					dol_syslog($this->error, LOG_WARNING);
@@ -478,8 +487,7 @@  discard block
 block discarded – undo
478 487
 				{
479 488
 					try {
480 489
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
481
-					}
482
-					catch (OdfException $e)
490
+					} catch (OdfException $e)
483 491
 					{
484 492
 						dol_syslog($e->getMessage(), LOG_WARNING);
485 493
 					}
@@ -498,8 +506,7 @@  discard block
 block discarded – undo
498 506
 						dol_syslog($e->getMessage(), LOG_WARNING);
499 507
 						return -1;
500 508
 					}
501
-				}
502
-				else {
509
+				} else {
503 510
 					try {
504 511
 						$odfHandler->saveToDisk($file);
505 512
 					} catch (Exception $e) {
@@ -511,16 +518,16 @@  discard block
 block discarded – undo
511 518
 
512 519
 				$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
513 520
 
514
-				if (! empty($conf->global->MAIN_UMASK))
515
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
521
+				if (! empty($conf->global->MAIN_UMASK)) {
522
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
523
+				}
516 524
 
517 525
 				$odfHandler=null;	// Destroy object
518 526
 
519 527
 				$this->result = array('fullpath'=>$file);
520 528
 
521 529
 				return 1;   // Success
522
-			}
523
-			else
530
+			} else
524 531
 			{
525 532
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526 533
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/usergroup/modules_usergroup.class.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -31,37 +31,37 @@
 block discarded – undo
31 31
  *  \brief      File with parent class for generating contracts to PDF and File of class to manage contract numbering
32 32
  */
33 33
 
34
- require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
34
+    require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
35 35
 
36 36
 /**
37 37
  *	Parent class to manage intervention document templates
38 38
  */
39 39
 abstract class ModelePDFUserGroup extends CommonDocGenerator
40 40
 {
41
-	/**
42
-	 * @var string Error code (or message)
43
-	 */
44
-	public $error='';
41
+    /**
42
+     * @var string Error code (or message)
43
+     */
44
+    public $error='';
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
48 48
     /**
49
-	 *	Return list of active generation modules
50
-	 *
49
+     *	Return list of active generation modules
50
+     *
51 51
      *  @param	DoliDB	$db     			Database handler
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates
54
-	 */
55
-	static function liste_modeles($db,$maxfilenamelength=0)
56
-	{
54
+     */
55
+    static function liste_modeles($db,$maxfilenamelength=0)
56
+    {
57 57
         // phpcs:enable
58
-		global $conf;
58
+        global $conf;
59 59
 
60
-		$type = 'group';
61
-		$list = array();
60
+        $type = 'group';
61
+        $list = array();
62 62
 
63
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
-		$list = getListOfModels($db, $type, $maxfilenamelength);
65
-		return $list;
66
-	}
63
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
+        $list = getListOfModels($db, $type, $maxfilenamelength);
65
+        return $list;
66
+    }
67 67
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * @var string Error code (or message)
43 43
 	 */
44
-	public $error='';
44
+	public $error = '';
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates
54 54
 	 */
55
-	static function liste_modeles($db,$maxfilenamelength=0)
55
+	static function liste_modeles($db, $maxfilenamelength = 0)
56 56
 	{
57 57
         // phpcs:enable
58 58
 		global $conf;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/ticket/mod_ticket_universal.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@
 block discarded – undo
41 41
     public $error = '';
42 42
 
43 43
     /**
44
-	 * @var string Nom du modele
45
-	 * @deprecated
46
-	 * @see name
47
-	 */
48
-	public $nom='Universal';
49
-
50
-	/**
51
-	 * @var string model name
52
-	 */
53
-	public $name='Universal';
44
+     * @var string Nom du modele
45
+     * @deprecated
46
+     * @see name
47
+     */
48
+    public $nom='Universal';
49
+
50
+    /**
51
+     * @var string model name
52
+     */
53
+    public $name='Universal';
54 54
 
55 55
     /**
56 56
      *  Renvoi la description du modele de numerotation
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
 	 * @deprecated
46 46
 	 * @see name
47 47
 	 */
48
-	public $nom='Universal';
48
+	public $nom = 'Universal';
49 49
 
50 50
 	/**
51 51
 	 * @var string model name
52 52
 	 */
53
-	public $name='Universal';
53
+	public $name = 'Universal';
54 54
 
55 55
     /**
56 56
      *  Renvoi la description du modele de numerotation
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
         global $conf, $langs;
63 63
 
64 64
         // Load translation files required by the page
65
-        $langs->loadLangs(array("ticket","admin"));
65
+        $langs->loadLangs(array("ticket", "admin"));
66 66
 
67 67
         $form = new Form($this->db);
68 68
 
69
-        $texte = $langs->trans('GenericNumRefModelDesc') . "<br>\n";
70
-        $texte .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
71
-        $texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
69
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
70
+        $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
71
+        $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
72 72
         $texte .= '<input type="hidden" name="action" value="updateMask">';
73 73
         $texte .= '<input type="hidden" name="maskconstticket" value="TICKET_UNIVERSAL_MASK">';
74 74
         $texte .= '<table class="nobordernopadding" width="100%">';
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
         $tooltip .= $langs->trans("GenericMaskCodes5");
81 81
 
82 82
         // Parametrage du prefix
83
-        $texte .= '<tr><td>' . $langs->trans("Mask") . ':</td>';
84
-        $texte .= '<td align="right">' . $form->textwithpicto('<input type="text" class="flat" size="24" name="maskticket" value="' . $conf->global->TICKET_UNIVERSAL_MASK . '">', $tooltip, 1, 1) . '</td>';
83
+        $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
84
+        $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskticket" value="'.$conf->global->TICKET_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
85 85
 
86
-        $texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button"></td>';
86
+        $texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
87 87
 
88 88
         $texte .= '</tr>';
89 89
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
         global $db, $conf;
126 126
 
127
-        include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
127
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
128 128
 
129 129
         // On defini critere recherche compteur
130 130
         $mask = $conf->global->TICKET_UNIVERSAL_MASK;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/ticket/mod_ticket_simple.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
37
+    public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39 39
     public $prefix = 'TS';
40 40
 
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     public $error = '';
45 45
 
46 46
     /**
47
-	 * @var string Nom du modele
48
-	 * @deprecated
49
-	 * @see name
50
-	 */
51
-	public $nom='Simple';
47
+     * @var string Nom du modele
48
+     * @deprecated
49
+     * @see name
50
+     */
51
+    public $nom='Simple';
52 52
 
53
-	/**
54
-	 * @var string model name
55
-	 */
56
-	public $name='Simple';
53
+    /**
54
+     * @var string model name
55
+     */
56
+    public $name='Simple';
57 57
 
58 58
     /**
59 59
      *  Return description of numbering module
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     /**
80
-  * Test si les numeros deja en vigueur dans la base ne provoquent pas de
80
+     * Test si les numeros deja en vigueur dans la base ne provoquent pas de
81 81
      *   de conflits qui empechera cette numerotation de fonctionner.
82 82
      *
83 83
      *   @return boolean     false si conflit, true si ok
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 	 * @deprecated
49 49
 	 * @see name
50 50
 	 */
51
-	public $nom='Simple';
51
+	public $nom = 'Simple';
52 52
 
53 53
 	/**
54 54
 	 * @var string model name
55 55
 	 */
56
-	public $name='Simple';
56
+	public $name = 'Simple';
57 57
 
58 58
     /**
59 59
      *  Return description of numbering module
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function getExample()
75 75
     {
76
-        return $this->prefix . "0501-0001";
76
+        return $this->prefix."0501-0001";
77 77
     }
78 78
 
79 79
     /**
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
         $max = '';
91 91
 
92 92
         $posindice = 8;
93
-        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
94
-        $sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
95
-        $search = $this->prefix . "____-%";
96
-        $sql .= " WHERE ref LIKE '" . $search ."'";
97
-        $sql .= " AND entity = " . $conf->entity;
93
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
94
+        $sql .= " FROM ".MAIN_DB_PREFIX."ticket";
95
+        $search = $this->prefix."____-%";
96
+        $sql .= " WHERE ref LIKE '".$search."'";
97
+        $sql .= " AND entity = ".$conf->entity;
98 98
         $resql = $db->query($sql);
99 99
         if ($resql) {
100 100
             $row = $db->fetch_row($resql);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 $max = $row[0];
104 104
             }
105 105
         }
106
-        if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
106
+        if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
107 107
             return true;
108 108
         } else {
109 109
             $langs->load("errors");
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 
126 126
         // D'abord on recupere la valeur max
127 127
         $posindice = 8;
128
-        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
129
-        $sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
130
-        $search = $this->prefix . "____-%";
131
-        $sql .= " WHERE ref LIKE '" . $search ."'";
132
-        $sql .= " AND entity = " . $conf->entity;
128
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
129
+        $sql .= " FROM ".MAIN_DB_PREFIX."ticket";
130
+        $search = $this->prefix."____-%";
131
+        $sql .= " WHERE ref LIKE '".$search."'";
132
+        $sql .= " AND entity = ".$conf->entity;
133 133
 
134 134
         $resql = $db->query($sql);
135 135
         if ($resql) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             $num = sprintf("%04s", $max + 1);
157 157
         }
158 158
 
159
-        dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
160
-        return $this->prefix . $yymm . "-" . $num;
159
+        dol_syslog("mod_ticket_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
160
+        return $this->prefix.$yymm."-".$num;
161 161
     }
162 162
 }
Please login to merge, or discard this patch.