Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
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.
dolibarr/htdocs/core/modules/modReception.class.php 3 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -31,251 +31,251 @@
 block discarded – undo
31 31
  */
32 32
 class modReception extends DolibarrModules
33 33
 {
34
-	/**
35
-	 *   Constructor. Define names, constants, directories, boxes, permissions
36
-	 *
37
-	 *   @param      DoliDB		$db      Database handler
38
-	 */
39
-	function __construct($db)
40
-	{
41
-		global $conf, $user;
42
-
43
-		$this->db = $db;
44
-		$this->numero = 104160;
45
-
46
-		$this->family = "srm";
47
-		$this->module_position = 40;
48
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		$this->description = "Gestion des réceptions fournisseurs";
51
-
52
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
-		$this->version = 'development';
54
-
55
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
-		$this->special = 0;
57
-		$this->picto = "sending";
58
-
59
-		// Data directories to create when module is enabled
60
-		$this->dirs = array("/reception/receipt",
61
-		                    "/reception/receipt/temp",
62
-		                    "/doctemplates/reception"
63
-		                    );
64
-
65
-		// Config pages
66
-		$this->config_page_url = array("reception_setup.php");
67
-
68
-		// Dependencies
69
-		$this->depends = array("modFournisseur");
70
-		$this->requiredby = array();
71
-		$this->conflictwith = array();
72
-		$this->langfiles = array('receptions');
73
-
74
-		// Constants
75
-		$this->const = array();
76
-		$r=0;
77
-
78
-		$this->const[$r][0] = "RECEPTION_ADDON_PDF";
79
-		$this->const[$r][1] = "chaine";
80
-		$this->const[$r][2] = "squille";
81
-		$this->const[$r][3] = 'Nom du gestionnaire de generation des bons receptions en PDF';
82
-		$this->const[$r][4] = 0;
83
-		$r++;
84
-
85
-		$this->const[$r][0] = "RECEPTION_ADDON_NUMBER";
86
-		$this->const[$r][1] = "chaine";
87
-		$this->const[$r][2] = "mod_reception_beryl";
88
-		$this->const[$r][3] = 'Name for numbering manager for receptions';
89
-		$this->const[$r][4] = 0;
90
-		$r++;
91
-
92
-		$this->const[$r][0] = "RECEPTION_ADDON_PDF_ODT_PATH";
93
-		$this->const[$r][1] = "chaine";
94
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/receptions";
95
-		$this->const[$r][3] = "";
96
-		$this->const[$r][4] = 0;
97
-		$r++;
98
-
99
-		$this->const[$r][0] = "MAIN_SUBMODULE_RECEPTION";
100
-		$this->const[$r][1] = "chaine";
101
-		$this->const[$r][2] = "1";
102
-		$this->const[$r][3] = "Enable receptions";
103
-		$this->const[$r][4] = 0;
104
-		$r++;
105
-
106
-		// Boxes
107
-		$this->boxes = array();
108
-
109
-		// Permissions
110
-		$this->rights = array();
111
-		$this->rights_class = 'reception';
112
-		$r=0;
113
-
114
-		$r++;
115
-		$this->rights[$r][0] = $this->numero.$r;
116
-		$this->rights[$r][1] = 'Lire les receptions';
117
-		$this->rights[$r][2] = 'r';
118
-		$this->rights[$r][3] = 0;
119
-		$this->rights[$r][4] = 'lire';
120
-
121
-		$r++;
122
-		$this->rights[$r][0] = $this->numero.$r;
123
-		$this->rights[$r][1] = 'Creer modifier les receptions';
124
-		$this->rights[$r][2] = 'w';
125
-		$this->rights[$r][3] = 0;
126
-		$this->rights[$r][4] = 'creer';
127
-
128
-		$r++;
129
-		$this->rights[$r][0] = $this->numero.$r;
130
-		$this->rights[$r][1] = 'Valider les receptions';
131
-		$this->rights[$r][2] = 'd';
132
-		$this->rights[$r][3] = 0;
133
-		$this->rights[$r][4] = 'reception_advance';
134
-		$this->rights[$r][5] = 'validate';
135
-
136
-		$r++;
137
-		$this->rights[$r][0] = $this->numero.$r; // id de la permission
138
-		$this->rights[$r][1] = 'Envoyer les receptions aux clients'; // libelle de la permission
139
-		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
140
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
141
-		$this->rights[$r][4] = 'reception_advance';
34
+    /**
35
+     *   Constructor. Define names, constants, directories, boxes, permissions
36
+     *
37
+     *   @param      DoliDB		$db      Database handler
38
+     */
39
+    function __construct($db)
40
+    {
41
+        global $conf, $user;
42
+
43
+        $this->db = $db;
44
+        $this->numero = 104160;
45
+
46
+        $this->family = "srm";
47
+        $this->module_position = 40;
48
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Gestion des réceptions fournisseurs";
51
+
52
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
+        $this->version = 'development';
54
+
55
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
+        $this->special = 0;
57
+        $this->picto = "sending";
58
+
59
+        // Data directories to create when module is enabled
60
+        $this->dirs = array("/reception/receipt",
61
+                            "/reception/receipt/temp",
62
+                            "/doctemplates/reception"
63
+                            );
64
+
65
+        // Config pages
66
+        $this->config_page_url = array("reception_setup.php");
67
+
68
+        // Dependencies
69
+        $this->depends = array("modFournisseur");
70
+        $this->requiredby = array();
71
+        $this->conflictwith = array();
72
+        $this->langfiles = array('receptions');
73
+
74
+        // Constants
75
+        $this->const = array();
76
+        $r=0;
77
+
78
+        $this->const[$r][0] = "RECEPTION_ADDON_PDF";
79
+        $this->const[$r][1] = "chaine";
80
+        $this->const[$r][2] = "squille";
81
+        $this->const[$r][3] = 'Nom du gestionnaire de generation des bons receptions en PDF';
82
+        $this->const[$r][4] = 0;
83
+        $r++;
84
+
85
+        $this->const[$r][0] = "RECEPTION_ADDON_NUMBER";
86
+        $this->const[$r][1] = "chaine";
87
+        $this->const[$r][2] = "mod_reception_beryl";
88
+        $this->const[$r][3] = 'Name for numbering manager for receptions';
89
+        $this->const[$r][4] = 0;
90
+        $r++;
91
+
92
+        $this->const[$r][0] = "RECEPTION_ADDON_PDF_ODT_PATH";
93
+        $this->const[$r][1] = "chaine";
94
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/receptions";
95
+        $this->const[$r][3] = "";
96
+        $this->const[$r][4] = 0;
97
+        $r++;
98
+
99
+        $this->const[$r][0] = "MAIN_SUBMODULE_RECEPTION";
100
+        $this->const[$r][1] = "chaine";
101
+        $this->const[$r][2] = "1";
102
+        $this->const[$r][3] = "Enable receptions";
103
+        $this->const[$r][4] = 0;
104
+        $r++;
105
+
106
+        // Boxes
107
+        $this->boxes = array();
108
+
109
+        // Permissions
110
+        $this->rights = array();
111
+        $this->rights_class = 'reception';
112
+        $r=0;
113
+
114
+        $r++;
115
+        $this->rights[$r][0] = $this->numero.$r;
116
+        $this->rights[$r][1] = 'Lire les receptions';
117
+        $this->rights[$r][2] = 'r';
118
+        $this->rights[$r][3] = 0;
119
+        $this->rights[$r][4] = 'lire';
120
+
121
+        $r++;
122
+        $this->rights[$r][0] = $this->numero.$r;
123
+        $this->rights[$r][1] = 'Creer modifier les receptions';
124
+        $this->rights[$r][2] = 'w';
125
+        $this->rights[$r][3] = 0;
126
+        $this->rights[$r][4] = 'creer';
127
+
128
+        $r++;
129
+        $this->rights[$r][0] = $this->numero.$r;
130
+        $this->rights[$r][1] = 'Valider les receptions';
131
+        $this->rights[$r][2] = 'd';
132
+        $this->rights[$r][3] = 0;
133
+        $this->rights[$r][4] = 'reception_advance';
134
+        $this->rights[$r][5] = 'validate';
135
+
136
+        $r++;
137
+        $this->rights[$r][0] = $this->numero.$r; // id de la permission
138
+        $this->rights[$r][1] = 'Envoyer les receptions aux clients'; // libelle de la permission
139
+        $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
140
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
141
+        $this->rights[$r][4] = 'reception_advance';
142 142
         $this->rights[$r][5] = 'send';
143 143
 
144
-		$r++;
145
-		$this->rights[$r][0] = $this->numero.$r;
146
-		$this->rights[$r][1] = 'Exporter les receptions';
147
-		$this->rights[$r][2] = 'r';
148
-		$this->rights[$r][3] = 0;
149
-		$this->rights[$r][4] = 'reception';
150
-		$this->rights[$r][5] = 'export';
151
-
152
-		$r++;
153
-		$this->rights[$r][0] = $this->numero.$r;
154
-		$this->rights[$r][1] = 'Supprimer les receptions';
155
-		$this->rights[$r][2] = 'd';
156
-		$this->rights[$r][3] = 0;
157
-		$this->rights[$r][4] = 'supprimer';
158
-
159
-
160
-		// Menus
161
-		//-------
162
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
163
-
164
-
165
-		// Exports
166
-		//--------
167
-		$r=0;
168
-
169
-		include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
170
-		$shipment=new CommandeFournisseur($this->db);
171
-		$contact_arrays=$shipment->liste_type_contact('external','',0,0,'');
172
-		if (is_array($contact_arrays) && count($contact_arrays)>0){
173
-			$idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,'')));
174
-		} else {
175
-			$idcontacts=0;
176
-		}
177
-
178
-
179
-		$r++;
180
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
181
-		$this->export_label[$r]='Receptions';	// Translation key (used only if key ExportDataset_xxx_z not found)
182
-		$this->export_permission[$r]=array(array("reception","reception","export"));
183
-		$this->export_fields_array[$r]=array(
184
-			's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
185
-			'd.nom'=>'State','co.label'=>'Country','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
186
-			'c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_supplier'=>"RefSupplier",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",'ed.rowid'=>'LineId',
187
-			'ed.comment'=>'Description','ed.qty'=>"Qty",
188
-			'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits'
189
-		);
190
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
191
-		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
192
-		$this->export_TypeFields_array[$r]=array(
193
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
194
-			'co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
195
-			'c.ref'=>"Text",'c.ref_supplier'=>"Text",'c.date_creation'=>"Date",'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
196
-			'ed.qty'=>"Numeric",'d.nom'=>'Text'
197
-		);
198
-		$this->export_entities_array[$r]=array(
199
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
200
-			'd.nom'=>'company','co.label'=>'company','co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
201
-			'c.rowid'=>"reception",'c.ref'=>"reception",'c.ref_supplier'=>"reception",'c.fk_soc'=>"reception",'c.date_creation'=>"reception",'c.date_delivery'=>"reception",'c.tracking_number'=>'reception','c.height'=>"reception",'c.width'=>"reception",'c.size'=>'reception','c.size_units'=>'reception','c.weight'=>"reception",'c.weight_units'=>'reception','c.fk_statut'=>"reception",'c.note_public'=>"reception",'ed.rowid'=>'reception_line','ed.comment'=>'reception_line','ed.qty'=>"reception_line",
202
-			'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product'
203
-		);
204
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
205
-		$this->export_dependencies_array[$r]=array('reception_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
206
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
207
-		{
208
-		    $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
209
-		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
210
-		}
211
-		$keyforselect='reception'; $keyforelement='reception'; $keyforaliasextra='extra';
212
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
213
-		$keyforselect='commande_fournisseur_dispatch'; $keyforelement='reception_line'; $keyforaliasextra='extra2';
214
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
215
-
216
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
217
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'reception as c';
218
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
219
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
220
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
221
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
222
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
223
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed';
224
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object';
225
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
226
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
227
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
228
-		{
229
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
230
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
231
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
232
-		}
233
-		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
234
-		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')';
235
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
236
-	}
237
-
238
-
239
-	/**
240
-	 *		Function called when module is enabled.
241
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
242
-	 *		It also creates data directories
243
-	 *
144
+        $r++;
145
+        $this->rights[$r][0] = $this->numero.$r;
146
+        $this->rights[$r][1] = 'Exporter les receptions';
147
+        $this->rights[$r][2] = 'r';
148
+        $this->rights[$r][3] = 0;
149
+        $this->rights[$r][4] = 'reception';
150
+        $this->rights[$r][5] = 'export';
151
+
152
+        $r++;
153
+        $this->rights[$r][0] = $this->numero.$r;
154
+        $this->rights[$r][1] = 'Supprimer les receptions';
155
+        $this->rights[$r][2] = 'd';
156
+        $this->rights[$r][3] = 0;
157
+        $this->rights[$r][4] = 'supprimer';
158
+
159
+
160
+        // Menus
161
+        //-------
162
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
163
+
164
+
165
+        // Exports
166
+        //--------
167
+        $r=0;
168
+
169
+        include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
170
+        $shipment=new CommandeFournisseur($this->db);
171
+        $contact_arrays=$shipment->liste_type_contact('external','',0,0,'');
172
+        if (is_array($contact_arrays) && count($contact_arrays)>0){
173
+            $idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,'')));
174
+        } else {
175
+            $idcontacts=0;
176
+        }
177
+
178
+
179
+        $r++;
180
+        $this->export_code[$r]=$this->rights_class.'_'.$r;
181
+        $this->export_label[$r]='Receptions';	// Translation key (used only if key ExportDataset_xxx_z not found)
182
+        $this->export_permission[$r]=array(array("reception","reception","export"));
183
+        $this->export_fields_array[$r]=array(
184
+            's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
185
+            'd.nom'=>'State','co.label'=>'Country','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
186
+            'c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_supplier'=>"RefSupplier",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",'ed.rowid'=>'LineId',
187
+            'ed.comment'=>'Description','ed.qty'=>"Qty",
188
+            'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits'
189
+        );
190
+        if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
191
+        //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
192
+        $this->export_TypeFields_array[$r]=array(
193
+            's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
194
+            'co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
195
+            'c.ref'=>"Text",'c.ref_supplier'=>"Text",'c.date_creation'=>"Date",'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
196
+            'ed.qty'=>"Numeric",'d.nom'=>'Text'
197
+        );
198
+        $this->export_entities_array[$r]=array(
199
+            's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
200
+            'd.nom'=>'company','co.label'=>'company','co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
201
+            'c.rowid'=>"reception",'c.ref'=>"reception",'c.ref_supplier'=>"reception",'c.fk_soc'=>"reception",'c.date_creation'=>"reception",'c.date_delivery'=>"reception",'c.tracking_number'=>'reception','c.height'=>"reception",'c.width'=>"reception",'c.size'=>'reception','c.size_units'=>'reception','c.weight'=>"reception",'c.weight_units'=>'reception','c.fk_statut'=>"reception",'c.note_public'=>"reception",'ed.rowid'=>'reception_line','ed.comment'=>'reception_line','ed.qty'=>"reception_line",
202
+            'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product'
203
+        );
204
+        if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
205
+        $this->export_dependencies_array[$r]=array('reception_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
206
+        if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
207
+        {
208
+            $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
209
+            include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
210
+        }
211
+        $keyforselect='reception'; $keyforelement='reception'; $keyforaliasextra='extra';
212
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
213
+        $keyforselect='commande_fournisseur_dispatch'; $keyforelement='reception_line'; $keyforaliasextra='extra2';
214
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
215
+
216
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
217
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'reception as c';
218
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
219
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
220
+        if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
221
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
222
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
223
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed';
224
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object';
225
+        $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
226
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
227
+        if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
228
+        {
229
+            $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
230
+            $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
231
+            $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
232
+        }
233
+        $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
234
+        $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')';
235
+        if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
236
+    }
237
+
238
+
239
+    /**
240
+     *		Function called when module is enabled.
241
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
242
+     *		It also creates data directories
243
+     *
244 244
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
245
-	 *      @return     int             	1 if OK, 0 if KO
246
-	 */
247
-	function init($options='')
248
-	{
249
-		global $conf,$langs;
250
-
251
-		// Permissions
252
-		$this->remove($options);
253
-
254
-		//ODT template
255
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/reception/template_reception.odt';
256
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/reception';
257
-		$dest=$dirodt.'/template_reception.odt';
258
-
259
-		if (file_exists($src) && ! file_exists($dest))
260
-		{
261
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
262
-			dol_mkdir($dirodt);
263
-			$result=dol_copy($src,$dest,0,0);
264
-			if ($result < 0)
265
-			{
266
-				$langs->load("errors");
267
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
268
-				return 0;
269
-			}
270
-		}
271
-
272
-		$sql = array();
273
-
274
-		$sql = array(
275
-			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".$conf->entity,
276
-			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".$conf->entity.")",
277
-		);
278
-
279
-		return $this->_init($sql,$options);
280
-	}
245
+     *      @return     int             	1 if OK, 0 if KO
246
+     */
247
+    function init($options='')
248
+    {
249
+        global $conf,$langs;
250
+
251
+        // Permissions
252
+        $this->remove($options);
253
+
254
+        //ODT template
255
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/reception/template_reception.odt';
256
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/reception';
257
+        $dest=$dirodt.'/template_reception.odt';
258
+
259
+        if (file_exists($src) && ! file_exists($dest))
260
+        {
261
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
262
+            dol_mkdir($dirodt);
263
+            $result=dol_copy($src,$dest,0,0);
264
+            if ($result < 0)
265
+            {
266
+                $langs->load("errors");
267
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
268
+                return 0;
269
+            }
270
+        }
271
+
272
+        $sql = array();
273
+
274
+        $sql = array(
275
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".$conf->entity,
276
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".$conf->entity.")",
277
+        );
278
+
279
+        return $this->_init($sql,$options);
280
+    }
281 281
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\brief      Fichier de description et activation du module Reception
24 24
  */
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
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->family = "srm";
47 47
 		$this->module_position = 40;
48 48
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Gestion des réceptions fournisseurs";
51 51
 
52 52
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
 		// Constants
75 75
 		$this->const = array();
76
-		$r=0;
76
+		$r = 0;
77 77
 
78 78
 		$this->const[$r][0] = "RECEPTION_ADDON_PDF";
79 79
 		$this->const[$r][1] = "chaine";
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		// Permissions
110 110
 		$this->rights = array();
111 111
 		$this->rights_class = 'reception';
112
-		$r=0;
112
+		$r = 0;
113 113
 
114 114
 		$r++;
115 115
 		$this->rights[$r][0] = $this->numero.$r;
@@ -159,80 +159,80 @@  discard block
 block discarded – undo
159 159
 
160 160
 		// Menus
161 161
 		//-------
162
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
162
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
163 163
 
164 164
 
165 165
 		// Exports
166 166
 		//--------
167
-		$r=0;
167
+		$r = 0;
168 168
 
169 169
 		include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
170
-		$shipment=new CommandeFournisseur($this->db);
171
-		$contact_arrays=$shipment->liste_type_contact('external','',0,0,'');
172
-		if (is_array($contact_arrays) && count($contact_arrays)>0){
173
-			$idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,'')));
170
+		$shipment = new CommandeFournisseur($this->db);
171
+		$contact_arrays = $shipment->liste_type_contact('external', '', 0, 0, '');
172
+		if (is_array($contact_arrays) && count($contact_arrays) > 0) {
173
+			$idcontacts = join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, '')));
174 174
 		} else {
175
-			$idcontacts=0;
175
+			$idcontacts = 0;
176 176
 		}
177 177
 
178 178
 
179 179
 		$r++;
180
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
181
-		$this->export_label[$r]='Receptions';	// Translation key (used only if key ExportDataset_xxx_z not found)
182
-		$this->export_permission[$r]=array(array("reception","reception","export"));
183
-		$this->export_fields_array[$r]=array(
184
-			's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
185
-			'd.nom'=>'State','co.label'=>'Country','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
186
-			'c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_supplier'=>"RefSupplier",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",'ed.rowid'=>'LineId',
187
-			'ed.comment'=>'Description','ed.qty'=>"Qty",
188
-			'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits'
180
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
181
+		$this->export_label[$r] = 'Receptions'; // Translation key (used only if key ExportDataset_xxx_z not found)
182
+		$this->export_permission[$r] = array(array("reception", "reception", "export"));
183
+		$this->export_fields_array[$r] = array(
184
+			's.rowid'=>"IdCompany", 's.nom'=>'ThirdParty', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town',
185
+			'd.nom'=>'State', 'co.label'=>'Country', 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
186
+			'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_supplier'=>"RefSupplier", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_delivery'=>"DateDeliveryPlanned", 'c.tracking_number'=>"TrackingNumber", 'c.height'=>"Height", 'c.width'=>"Width", 'c.size'=>"Depth", 'c.size_units'=>'SizeUnits', 'c.weight'=>"Weight", 'c.weight_units'=>"WeightUnits", 'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic", 'ed.rowid'=>'LineId',
187
+			'ed.comment'=>'Description', 'ed.qty'=>"Qty",
188
+			'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.weight'=>'ProductWeight', 'p.weight_units'=>'WeightUnits', 'p.volume'=>'ProductVolume', 'p.volume_units'=>'VolumeUnits'
189 189
 		);
190
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
190
+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');
191 191
 		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
192
-		$this->export_TypeFields_array[$r]=array(
193
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
194
-			'co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
195
-			'c.ref'=>"Text",'c.ref_supplier'=>"Text",'c.date_creation'=>"Date",'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
196
-			'ed.qty'=>"Numeric",'d.nom'=>'Text'
192
+		$this->export_TypeFields_array[$r] = array(
193
+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text',
194
+			'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text',
195
+			'c.ref'=>"Text", 'c.ref_supplier'=>"Text", 'c.date_creation'=>"Date", 'c.date_delivery'=>"Date", 'c.tracking_number'=>"Numeric", 'c.height'=>"Numeric", 'c.width'=>"Numeric", 'c.weight'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text",
196
+			'ed.qty'=>"Numeric", 'd.nom'=>'Text'
197 197
 		);
198
-		$this->export_entities_array[$r]=array(
199
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
200
-			'd.nom'=>'company','co.label'=>'company','co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
201
-			'c.rowid'=>"reception",'c.ref'=>"reception",'c.ref_supplier'=>"reception",'c.fk_soc'=>"reception",'c.date_creation'=>"reception",'c.date_delivery'=>"reception",'c.tracking_number'=>'reception','c.height'=>"reception",'c.width'=>"reception",'c.size'=>'reception','c.size_units'=>'reception','c.weight'=>"reception",'c.weight_units'=>'reception','c.fk_statut'=>"reception",'c.note_public'=>"reception",'ed.rowid'=>'reception_line','ed.comment'=>'reception_line','ed.qty'=>"reception_line",
202
-			'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product'
198
+		$this->export_entities_array[$r] = array(
199
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
200
+			'd.nom'=>'company', 'co.label'=>'company', 'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
201
+			'c.rowid'=>"reception", 'c.ref'=>"reception", 'c.ref_supplier'=>"reception", 'c.fk_soc'=>"reception", 'c.date_creation'=>"reception", 'c.date_delivery'=>"reception", 'c.tracking_number'=>'reception', 'c.height'=>"reception", 'c.width'=>"reception", 'c.size'=>'reception', 'c.size_units'=>'reception', 'c.weight'=>"reception", 'c.weight_units'=>'reception', 'c.fk_statut'=>"reception", 'c.note_public'=>"reception", 'ed.rowid'=>'reception_line', 'ed.comment'=>'reception_line', 'ed.qty'=>"reception_line",
202
+			'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product'
203 203
 		);
204
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
205
-		$this->export_dependencies_array[$r]=array('reception_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
206
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
204
+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');
205
+		$this->export_dependencies_array[$r] = array('reception_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
206
+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
207 207
 		{
208
-		    $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
208
+		    $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3';
209 209
 		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
210 210
 		}
211
-		$keyforselect='reception'; $keyforelement='reception'; $keyforaliasextra='extra';
211
+		$keyforselect = 'reception'; $keyforelement = 'reception'; $keyforaliasextra = 'extra';
212 212
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
213
-		$keyforselect='commande_fournisseur_dispatch'; $keyforelement='reception_line'; $keyforaliasextra='extra2';
213
+		$keyforselect = 'commande_fournisseur_dispatch'; $keyforelement = 'reception_line'; $keyforaliasextra = 'extra2';
214 214
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
215 215
 
216
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
217
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'reception as c';
218
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
219
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
220
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
221
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
222
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
223
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed';
224
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object';
225
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
226
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
227
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
216
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
217
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'reception as c';
218
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
219
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
220
+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
221
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
222
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
223
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed';
224
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object';
225
+		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
226
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
227
+		if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
228 228
 		{
229
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
230
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
231
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
229
+		  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
230
+		  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
231
+		  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
232 232
 		}
233
-		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
234
-		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')';
235
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
233
+		$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
234
+		$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('reception').')';
235
+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
236 236
 	}
237 237
 
238 238
 
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
245 245
 	 *      @return     int             	1 if OK, 0 if KO
246 246
 	 */
247
-	function init($options='')
247
+	function init($options = '')
248 248
 	{
249
-		global $conf,$langs;
249
+		global $conf, $langs;
250 250
 
251 251
 		// Permissions
252 252
 		$this->remove($options);
253 253
 
254 254
 		//ODT template
255
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/reception/template_reception.odt';
256
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/reception';
257
-		$dest=$dirodt.'/template_reception.odt';
255
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/reception/template_reception.odt';
256
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/reception';
257
+		$dest = $dirodt.'/template_reception.odt';
258 258
 
259
-		if (file_exists($src) && ! file_exists($dest))
259
+		if (file_exists($src) && !file_exists($dest))
260 260
 		{
261 261
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
262 262
 			dol_mkdir($dirodt);
263
-			$result=dol_copy($src,$dest,0,0);
263
+			$result = dol_copy($src, $dest, 0, 0);
264 264
 			if ($result < 0)
265 265
 			{
266 266
 				$langs->load("errors");
267
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
267
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
268 268
 				return 0;
269 269
 			}
270 270
 		}
@@ -276,6 +276,6 @@  discard block
 block discarded – undo
276 276
 			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".$conf->entity.")",
277 277
 		);
278 278
 
279
-		return $this->_init($sql,$options);
279
+		return $this->_init($sql, $options);
280 280
 	}
281 281
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -187,7 +187,9 @@  discard block
 block discarded – undo
187 187
 			'ed.comment'=>'Description','ed.qty'=>"Qty",
188 188
 			'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits'
189 189
 		);
190
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
190
+		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) {
191
+		    $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
192
+		}
191 193
 		//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
192 194
 		$this->export_TypeFields_array[$r]=array(
193 195
 			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
@@ -201,7 +203,9 @@  discard block
 block discarded – undo
201 203
 			'c.rowid'=>"reception",'c.ref'=>"reception",'c.ref_supplier'=>"reception",'c.fk_soc'=>"reception",'c.date_creation'=>"reception",'c.date_delivery'=>"reception",'c.tracking_number'=>'reception','c.height'=>"reception",'c.width'=>"reception",'c.size'=>'reception','c.size_units'=>'reception','c.weight'=>"reception",'c.weight_units'=>'reception','c.fk_statut'=>"reception",'c.note_public'=>"reception",'ed.rowid'=>'reception_line','ed.comment'=>'reception_line','ed.qty'=>"reception_line",
202 204
 			'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product'
203 205
 		);
204
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
206
+		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) {
207
+		    $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
208
+		}
205 209
 		$this->export_dependencies_array[$r]=array('reception_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
206 210
 		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
207 211
 		{
@@ -217,7 +221,9 @@  discard block
 block discarded – undo
217 221
 		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'reception as c';
218 222
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
219 223
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
220
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
224
+		if(!$user->rights->societe->client->voir) {
225
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
226
+		}
221 227
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
222 228
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
223 229
 		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed';
@@ -232,7 +238,9 @@  discard block
 block discarded – undo
232 238
 		}
233 239
 		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
234 240
 		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')';
235
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
241
+		if(!$user->rights->societe->client->voir) {
242
+		    $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
243
+		}
236 244
 	}
237 245
 
238 246
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/doc/pdf_strato.modules.php 3 patches
Indentation   +596 added lines, -596 removed lines patch added patch discarded remove patch
@@ -40,125 +40,125 @@  discard block
 block discarded – undo
40 40
  */
41 41
 class pdf_strato extends ModelePDFContract
42 42
 {
43
-	/**
43
+    /**
44 44
      * @var DoliDb Database handler
45 45
      */
46 46
     public $db;
47 47
 
48
-	/**
48
+    /**
49 49
      * @var string model name
50 50
      */
51 51
     public $name;
52 52
 
53
-	/**
53
+    /**
54 54
      * @var string model description (short text)
55 55
      */
56 56
     public $description;
57 57
 
58
-	/**
58
+    /**
59 59
      * @var string document type
60 60
      */
61 61
     public $type;
62 62
 
63
-	/**
63
+    /**
64 64
      * @var array() Minimum version of PHP required by module.
65
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
65
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
66 66
      */
67
-	public $phpmin = array(5, 4);
67
+    public $phpmin = array(5, 4);
68 68
 
69
-	/**
69
+    /**
70 70
      * Dolibarr version of the loaded document
71 71
      * @public string
72 72
      */
73
-	public $version = 'dolibarr';
73
+    public $version = 'dolibarr';
74 74
 
75
-	/**
75
+    /**
76 76
      * @var int page_largeur
77 77
      */
78 78
     public $page_largeur;
79 79
 
80
-	/**
80
+    /**
81 81
      * @var int page_hauteur
82 82
      */
83 83
     public $page_hauteur;
84 84
 
85
-	/**
85
+    /**
86 86
      * @var array format
87 87
      */
88 88
     public $format;
89 89
 
90
-	/**
90
+    /**
91 91
      * @var int marge_gauche
92 92
      */
93
-	public $marge_gauche;
93
+    public $marge_gauche;
94 94
 
95
-	/**
95
+    /**
96 96
      * @var int marge_droite
97 97
      */
98
-	public $marge_droite;
98
+    public $marge_droite;
99 99
 
100
-	/**
100
+    /**
101 101
      * @var int marge_haute
102 102
      */
103
-	public $marge_haute;
103
+    public $marge_haute;
104 104
 
105
-	/**
105
+    /**
106 106
      * @var int marge_basse
107 107
      */
108
-	public $marge_basse;
109
-
110
-	/**
111
-	 * Issuer
112
-	 * @var Societe
113
-	 */
114
-	public $emetteur;
115
-
116
-	/**
117
-	 * Recipient
118
-	 * @var Societe
119
-	 */
120
-	public $recipient;
121
-
122
-	/**
123
-	 *	Constructor
124
-	 *
125
-	 *  @param		DoliDB		$db      Database handler
126
-	 */
127
-	function __construct($db)
128
-	{
129
-		global $conf,$langs,$mysoc;
130
-
131
-		$this->db = $db;
132
-		$this->name = 'strato';
133
-		$this->description = $langs->trans("StandardContractsTemplate");
134
-
135
-		// Dimension page pour format A4
136
-		$this->type = 'pdf';
137
-		$formatarray=pdf_getFormat();
138
-
139
-		$this->page_largeur = $formatarray['width'];
140
-		$this->page_hauteur = $formatarray['height'];
141
-		$this->format = array($this->page_largeur,$this->page_hauteur);
142
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
143
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
144
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
145
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
146
-
147
-		$this->option_logo = 1;                    // Affiche logo
148
-		$this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
149
-		$this->option_modereg = 0;                 // Affiche mode reglement
150
-		$this->option_condreg = 0;                 // Affiche conditions reglement
151
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
152
-		$this->option_multilang = 0;               // Dispo en plusieurs langues
153
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
154
-
155
-		// Get source company
156
-		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
158
-
159
-		// Define position of columns
160
-		$this->posxdesc=$this->marge_gauche+1;
161
-	}
108
+    public $marge_basse;
109
+
110
+    /**
111
+     * Issuer
112
+     * @var Societe
113
+     */
114
+    public $emetteur;
115
+
116
+    /**
117
+     * Recipient
118
+     * @var Societe
119
+     */
120
+    public $recipient;
121
+
122
+    /**
123
+     *	Constructor
124
+     *
125
+     *  @param		DoliDB		$db      Database handler
126
+     */
127
+    function __construct($db)
128
+    {
129
+        global $conf,$langs,$mysoc;
130
+
131
+        $this->db = $db;
132
+        $this->name = 'strato';
133
+        $this->description = $langs->trans("StandardContractsTemplate");
134
+
135
+        // Dimension page pour format A4
136
+        $this->type = 'pdf';
137
+        $formatarray=pdf_getFormat();
138
+
139
+        $this->page_largeur = $formatarray['width'];
140
+        $this->page_hauteur = $formatarray['height'];
141
+        $this->format = array($this->page_largeur,$this->page_hauteur);
142
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
143
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
144
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
145
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
146
+
147
+        $this->option_logo = 1;                    // Affiche logo
148
+        $this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
149
+        $this->option_modereg = 0;                 // Affiche mode reglement
150
+        $this->option_condreg = 0;                 // Affiche conditions reglement
151
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
152
+        $this->option_multilang = 0;               // Dispo en plusieurs langues
153
+        $this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
154
+
155
+        // Get source company
156
+        $this->emetteur=$mysoc;
157
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
158
+
159
+        // Define position of columns
160
+        $this->posxdesc=$this->marge_gauche+1;
161
+    }
162 162
 
163 163
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
164 164
     /**
@@ -171,64 +171,64 @@  discard block
 block discarded – undo
171 171
      *  @param		int				$hidedesc			Do not show desc
172 172
      *  @param		int				$hideref			Do not show ref
173 173
      *  @return		int									1=OK, 0=KO
174
-	 */
175
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
176
-	{
174
+     */
175
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
176
+    {
177 177
         // phpcs:enable
178
-		global $user,$langs,$conf,$hookmanager,$mysoc;
178
+        global $user,$langs,$conf,$hookmanager,$mysoc;
179 179
 
180
-		if (! is_object($outputlangs)) $outputlangs=$langs;
181
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
180
+        if (! is_object($outputlangs)) $outputlangs=$langs;
181
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
183 183
 
184
-		// Load traductions files requiredby by page
185
-		$outputlangs->loadLangs(array("main", "dict", "companies", "contracts"));
184
+        // Load traductions files requiredby by page
185
+        $outputlangs->loadLangs(array("main", "dict", "companies", "contracts"));
186 186
 
187
-		if ($conf->contrat->dir_output)
188
-		{
187
+        if ($conf->contrat->dir_output)
188
+        {
189 189
             $object->fetch_thirdparty();
190 190
 
191
-			// Definition of $dir and $file
192
-			if ($object->specimen)
193
-			{
194
-				$dir = $conf->contrat->dir_output;
195
-				$file = $dir . "/SPECIMEN.pdf";
196
-			}
197
-			else
198
-			{
199
-				$objectref = dol_sanitizeFileName($object->ref);
200
-				$dir = $conf->contrat->dir_output . "/" . $objectref;
201
-				$file = $dir . "/" . $objectref . ".pdf";
202
-			}
203
-
204
-			if (! file_exists($dir))
205
-			{
206
-				if (dol_mkdir($dir) < 0)
207
-				{
208
-					$this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
209
-					return 0;
210
-				}
211
-			}
212
-
213
-			if (file_exists($dir))
214
-			{
215
-				// Add pdfgeneration hook
216
-				if (! is_object($hookmanager))
217
-				{
218
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
219
-					$hookmanager=new HookManager($this->db);
220
-				}
221
-				$hookmanager->initHooks(array('pdfgeneration'));
222
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
223
-				global $action;
224
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
191
+            // Definition of $dir and $file
192
+            if ($object->specimen)
193
+            {
194
+                $dir = $conf->contrat->dir_output;
195
+                $file = $dir . "/SPECIMEN.pdf";
196
+            }
197
+            else
198
+            {
199
+                $objectref = dol_sanitizeFileName($object->ref);
200
+                $dir = $conf->contrat->dir_output . "/" . $objectref;
201
+                $file = $dir . "/" . $objectref . ".pdf";
202
+            }
203
+
204
+            if (! file_exists($dir))
205
+            {
206
+                if (dol_mkdir($dir) < 0)
207
+                {
208
+                    $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
209
+                    return 0;
210
+                }
211
+            }
212
+
213
+            if (file_exists($dir))
214
+            {
215
+                // Add pdfgeneration hook
216
+                if (! is_object($hookmanager))
217
+                {
218
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
219
+                    $hookmanager=new HookManager($this->db);
220
+                }
221
+                $hookmanager->initHooks(array('pdfgeneration'));
222
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
223
+                global $action;
224
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
225 225
 
226 226
                 $pdf=pdf_getInstance($this->format);
227 227
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
228 228
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
229
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
230
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
231
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
229
+                $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
230
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
231
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
232 232
                 $pdf->SetAutoPageBreak(1,0);
233 233
 
234 234
                 if (class_exists('TCPDF'))
@@ -244,279 +244,279 @@  discard block
 block discarded – undo
244 244
                     $tplidx = $pdf->importPage(1);
245 245
                 }
246 246
 
247
-				$pdf->Open();
248
-				$pagenb=0;
249
-				$pdf->SetDrawColor(128,128,128);
250
-
251
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
252
-				$pdf->SetSubject($outputlangs->transnoentities("ContractCard"));
253
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
254
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
255
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
256
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
257
-
258
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
259
-
260
-				// New page
261
-				$pdf->AddPage();
262
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
263
-				$pagenb++;
264
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
265
-				$pdf->SetFont('','', $default_font_size - 1);
266
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
267
-				$pdf->SetTextColor(0,0,0);
268
-
269
-				$tab_top = 90;
270
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
271
-
272
-				// Affiche notes
273
-				if (! empty($object->note_public))
274
-				{
275
-					$tab_top -= 2;
276
-
277
-					$pdf->SetFont('','', $default_font_size - 1);
278
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
279
-					$nexY = $pdf->GetY();
280
-					$height_note=$nexY-$tab_top;
281
-
282
-					// Rect prend une longueur en 3eme param
283
-					$pdf->SetDrawColor(192,192,192);
284
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
285
-
286
-					$tab_top = $nexY+6;
287
-				}
288
-
289
-				$iniY = $tab_top + 7;
290
-				$curY = $tab_top + 7;
291
-				$nexY = $tab_top + 2;
292
-
293
-				$pdf->SetXY($this->marge_gauche, $tab_top);
294
-
295
-				$pdf->MultiCell(0, 2, '');		// Set interline to 3. Then writeMultiCell must use 3 also.
296
-
297
-				$nblines = count($object->lines);
298
-
299
-				// Loop on each lines
300
-				for ($i = 0; $i < $nblines; $i++)
301
-				{
302
-					$objectligne = $object->lines[$i];
303
-
304
-					$valide = $objectligne->id ? 1 : 0;
305
-
306
-					if ($valide > 0 || $object->specimen)
307
-					{
308
-						$curX = $this->posxdesc-1;
309
-						$curY = $nexY;
310
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
311
-						$pdf->SetTextColor(0,0,0);
312
-
313
-						$pdf->setTopMargin($tab_top_newpage);
314
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
315
-						$pageposbefore=$pdf->getPage();
316
-
317
-						// Description of product line
318
-
319
-						if ($objectligne->date_ouverture_prevue) {
320
-							$datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true);
321
-						} else {
322
-							$datei = $langs->trans("Unknown");
323
-						}
324
-
325
-						if ($objectligne->date_fin_validite) {
326
-							$durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour');
327
-							$datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true);
328
-						} else {
329
-							$durationi = $langs->trans("Unknown");
330
-							$datee = $langs->trans("Unknown");
331
-						}
332
-
333
-						if ($objectligne->date_ouverture) {
334
-							$daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true);
335
-						} else {
336
-							$daters = $langs->trans("Unknown");
337
-						}
338
-
339
-						if ($objectligne->date_cloture) {
340
-							$datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true);
341
-						} else {
342
-							$datere = $langs->trans("Unknown");
343
-						}
344
-
345
-						$txtpredefinedservice='';
247
+                $pdf->Open();
248
+                $pagenb=0;
249
+                $pdf->SetDrawColor(128,128,128);
250
+
251
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
252
+                $pdf->SetSubject($outputlangs->transnoentities("ContractCard"));
253
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
254
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
255
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
256
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
257
+
258
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
259
+
260
+                // New page
261
+                $pdf->AddPage();
262
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
263
+                $pagenb++;
264
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
265
+                $pdf->SetFont('','', $default_font_size - 1);
266
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
267
+                $pdf->SetTextColor(0,0,0);
268
+
269
+                $tab_top = 90;
270
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
271
+
272
+                // Affiche notes
273
+                if (! empty($object->note_public))
274
+                {
275
+                    $tab_top -= 2;
276
+
277
+                    $pdf->SetFont('','', $default_font_size - 1);
278
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
279
+                    $nexY = $pdf->GetY();
280
+                    $height_note=$nexY-$tab_top;
281
+
282
+                    // Rect prend une longueur en 3eme param
283
+                    $pdf->SetDrawColor(192,192,192);
284
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
285
+
286
+                    $tab_top = $nexY+6;
287
+                }
288
+
289
+                $iniY = $tab_top + 7;
290
+                $curY = $tab_top + 7;
291
+                $nexY = $tab_top + 2;
292
+
293
+                $pdf->SetXY($this->marge_gauche, $tab_top);
294
+
295
+                $pdf->MultiCell(0, 2, '');		// Set interline to 3. Then writeMultiCell must use 3 also.
296
+
297
+                $nblines = count($object->lines);
298
+
299
+                // Loop on each lines
300
+                for ($i = 0; $i < $nblines; $i++)
301
+                {
302
+                    $objectligne = $object->lines[$i];
303
+
304
+                    $valide = $objectligne->id ? 1 : 0;
305
+
306
+                    if ($valide > 0 || $object->specimen)
307
+                    {
308
+                        $curX = $this->posxdesc-1;
309
+                        $curY = $nexY;
310
+                        $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
311
+                        $pdf->SetTextColor(0,0,0);
312
+
313
+                        $pdf->setTopMargin($tab_top_newpage);
314
+                        $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
315
+                        $pageposbefore=$pdf->getPage();
316
+
317
+                        // Description of product line
318
+
319
+                        if ($objectligne->date_ouverture_prevue) {
320
+                            $datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true);
321
+                        } else {
322
+                            $datei = $langs->trans("Unknown");
323
+                        }
324
+
325
+                        if ($objectligne->date_fin_validite) {
326
+                            $durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour');
327
+                            $datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true);
328
+                        } else {
329
+                            $durationi = $langs->trans("Unknown");
330
+                            $datee = $langs->trans("Unknown");
331
+                        }
332
+
333
+                        if ($objectligne->date_ouverture) {
334
+                            $daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true);
335
+                        } else {
336
+                            $daters = $langs->trans("Unknown");
337
+                        }
338
+
339
+                        if ($objectligne->date_cloture) {
340
+                            $datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true);
341
+                        } else {
342
+                            $datere = $langs->trans("Unknown");
343
+                        }
344
+
345
+                        $txtpredefinedservice='';
346 346
                         $txtpredefinedservice = $objectligne->product_label;
347 347
                         if ($objectligne->product_label)
348 348
                         {
349
-                        	$txtpredefinedservice .= ' - ';
350
-                        	$txtpredefinedservice .= $objectligne->product_label;
349
+                            $txtpredefinedservice .= ' - ';
350
+                            $txtpredefinedservice .= $objectligne->product_label;
351 351
                         }
352 352
 
353
-						$desc=dol_htmlentitiesbr($objectligne->desc,1);   // Desc (not empty for free lines)
354
-						$txt='';
355
-						$txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>';   // Desc (not empty for free lines)
356
-						$txt.='<br>';
357
-						$txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
358
-						$txt.='<br>';
353
+                        $desc=dol_htmlentitiesbr($objectligne->desc,1);   // Desc (not empty for free lines)
354
+                        $txt='';
355
+                        $txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>';   // Desc (not empty for free lines)
356
+                        $txt.='<br>';
357
+                        $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
358
+                        $txt.='<br>';
359 359
                         $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
360
-						if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
361
-
362
-						$pdf->startTransaction();
363
-						$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
364
-						$pageposafter=$pdf->getPage();
365
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
366
-						{
367
-							$pdf->rollbackTransaction(true);
368
-							$pageposafter=$pageposbefore;
369
-							//print $pageposafter.'-'.$pageposbefore;exit;
370
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371
-							$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
372
-							$pageposafter=$pdf->getPage();
373
-							$posyafter=$pdf->GetY();
374
-
375
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
376
-							{
377
-								if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
378
-								{
379
-									$pdf->AddPage('','',true);
380
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
382
-									$pdf->setPage($pageposafter+1);
383
-								}
384
-							}
385
-							else
386
-							{
387
-								// We found a page break
388
-								$showpricebeforepagebreak=0;
389
-							}
390
-						}
391
-						else	// No pagebreak
392
-						{
393
-							$pdf->commitTransaction();
394
-						}
395
-
396
-						$nexY = $pdf->GetY() + 2;
397
-						$pageposafter=$pdf->getPage();
398
-
399
-						$pdf->setPage($pageposbefore);
400
-						$pdf->setTopMargin($this->marge_haute);
401
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
402
-
403
-						// We suppose that a too long description is moved completely on next page
404
-						if ($pageposafter > $pageposbefore) {
405
-							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
406
-						}
407
-
408
-						$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
409
-
410
-						// Detect if some page were added automatically and output _tableau for past pages
411
-						while ($pagenb < $pageposafter)
412
-						{
413
-							$pdf->setPage($pagenb);
414
-							if ($pagenb == 1)
415
-							{
416
-								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
417
-							}
418
-							else
419
-							{
420
-								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
421
-							}
422
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
423
-							$pagenb++;
424
-							$pdf->setPage($pagenb);
425
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
426
-						}
427
-
428
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
429
-						{
430
-							if ($pagenb == 1)
431
-							{
432
-								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
433
-							}
434
-							else
435
-							{
436
-								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
437
-							}
438
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
439
-							// New page
440
-							$pdf->AddPage();
441
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
442
-							$pagenb++;
443
-						}
444
-					}
445
-				}
446
-
447
-				// Show square
448
-				if ($pagenb == 1)
449
-				{
450
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
451
-					$this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
452
-					$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
453
-				}
454
-				else
455
-				{
456
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
457
-					$this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
458
-					$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
459
-				}
460
-
461
-				$this->_pagefoot($pdf,$object,$outputlangs);
462
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
463
-
464
-				$pdf->Close();
465
-
466
-				$pdf->Output($file,'F');
467
-
468
-				// Add pdfgeneration hook
469
-				if (! is_object($hookmanager))
470
-				{
471
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
472
-					$hookmanager=new HookManager($this->db);
473
-				}
474
-				$hookmanager->initHooks(array('pdfgeneration'));
475
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
476
-				global $action;
477
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
478
-
479
-				if (! empty($conf->global->MAIN_UMASK))
480
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
481
-
482
-				$this->result = array('fullpath'=>$file);
483
-
484
-				return 1;
485
-			}
486
-			else
487
-			{
488
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
489
-				return 0;
490
-			}
491
-		}
492
-		else
493
-		{
494
-			$this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
495
-			return 0;
496
-		}
497
-	}
498
-
499
-	/**
500
-	 *   Show table for lines
501
-	 *
502
-	 *   @param		PDF			$pdf     		Object PDF
503
-	 *   @param		string		$tab_top		Top position of table
504
-	 *   @param		string		$tab_height		Height of table (rectangle)
505
-	 *   @param		int			$nexY			Y
506
-	 *   @param		Translate	$outputlangs	Langs object
507
-	 *   @param		int			$hidetop		Hide top bar of array
508
-	 *   @param		int			$hidebottom		Hide bottom bar of array
509
-	 *   @return	void
510
-	 */
511
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
512
-	{
513
-		global $conf;
514
-
515
-		// Force to disable hidetop and hidebottom
516
-		$hidebottom=0;
517
-		if ($hidetop) $hidetop=-1;
518
-
519
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
360
+                        if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
361
+
362
+                        $pdf->startTransaction();
363
+                        $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
364
+                        $pageposafter=$pdf->getPage();
365
+                        if ($pageposafter > $pageposbefore)	// There is a pagebreak
366
+                        {
367
+                            $pdf->rollbackTransaction(true);
368
+                            $pageposafter=$pageposbefore;
369
+                            //print $pageposafter.'-'.$pageposbefore;exit;
370
+                            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
371
+                            $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
372
+                            $pageposafter=$pdf->getPage();
373
+                            $posyafter=$pdf->GetY();
374
+
375
+                            if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
376
+                            {
377
+                                if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
378
+                                {
379
+                                    $pdf->AddPage('','',true);
380
+                                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381
+                                    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
382
+                                    $pdf->setPage($pageposafter+1);
383
+                                }
384
+                            }
385
+                            else
386
+                            {
387
+                                // We found a page break
388
+                                $showpricebeforepagebreak=0;
389
+                            }
390
+                        }
391
+                        else	// No pagebreak
392
+                        {
393
+                            $pdf->commitTransaction();
394
+                        }
395
+
396
+                        $nexY = $pdf->GetY() + 2;
397
+                        $pageposafter=$pdf->getPage();
398
+
399
+                        $pdf->setPage($pageposbefore);
400
+                        $pdf->setTopMargin($this->marge_haute);
401
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
402
+
403
+                        // We suppose that a too long description is moved completely on next page
404
+                        if ($pageposafter > $pageposbefore) {
405
+                            $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
406
+                        }
407
+
408
+                        $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
409
+
410
+                        // Detect if some page were added automatically and output _tableau for past pages
411
+                        while ($pagenb < $pageposafter)
412
+                        {
413
+                            $pdf->setPage($pagenb);
414
+                            if ($pagenb == 1)
415
+                            {
416
+                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
417
+                            }
418
+                            else
419
+                            {
420
+                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
421
+                            }
422
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
423
+                            $pagenb++;
424
+                            $pdf->setPage($pagenb);
425
+                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
426
+                        }
427
+
428
+                        if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
429
+                        {
430
+                            if ($pagenb == 1)
431
+                            {
432
+                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
433
+                            }
434
+                            else
435
+                            {
436
+                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
437
+                            }
438
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
439
+                            // New page
440
+                            $pdf->AddPage();
441
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
442
+                            $pagenb++;
443
+                        }
444
+                    }
445
+                }
446
+
447
+                // Show square
448
+                if ($pagenb == 1)
449
+                {
450
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
451
+                    $this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
452
+                    $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
453
+                }
454
+                else
455
+                {
456
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
457
+                    $this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
458
+                    $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
459
+                }
460
+
461
+                $this->_pagefoot($pdf,$object,$outputlangs);
462
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
463
+
464
+                $pdf->Close();
465
+
466
+                $pdf->Output($file,'F');
467
+
468
+                // Add pdfgeneration hook
469
+                if (! is_object($hookmanager))
470
+                {
471
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
472
+                    $hookmanager=new HookManager($this->db);
473
+                }
474
+                $hookmanager->initHooks(array('pdfgeneration'));
475
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
476
+                global $action;
477
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
478
+
479
+                if (! empty($conf->global->MAIN_UMASK))
480
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
481
+
482
+                $this->result = array('fullpath'=>$file);
483
+
484
+                return 1;
485
+            }
486
+            else
487
+            {
488
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
489
+                return 0;
490
+            }
491
+        }
492
+        else
493
+        {
494
+            $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
495
+            return 0;
496
+        }
497
+    }
498
+
499
+    /**
500
+     *   Show table for lines
501
+     *
502
+     *   @param		PDF			$pdf     		Object PDF
503
+     *   @param		string		$tab_top		Top position of table
504
+     *   @param		string		$tab_height		Height of table (rectangle)
505
+     *   @param		int			$nexY			Y
506
+     *   @param		Translate	$outputlangs	Langs object
507
+     *   @param		int			$hidetop		Hide top bar of array
508
+     *   @param		int			$hidebottom		Hide bottom bar of array
509
+     *   @return	void
510
+     */
511
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
512
+    {
513
+        global $conf;
514
+
515
+        // Force to disable hidetop and hidebottom
516
+        $hidebottom=0;
517
+        if ($hidetop) $hidetop=-1;
518
+
519
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
520 520
 /*
521 521
 		$pdf->SetXY($this->marge_gauche, $tab_top);
522 522
 		$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 		$pdf->MultiCell(0, 3, '');		// Set interline to 3. Then writeMultiCell must use 3 also.
544 544
 */
545 545
 
546
-		// Output Rect
547
-		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3);	// Rect prend une longueur en 3eme param et 4eme param
548
-	}
546
+        // Output Rect
547
+        $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3);	// Rect prend une longueur en 3eme param et 4eme param
548
+    }
549 549
 
550 550
     /**
551 551
      * Show footer signature of page
@@ -555,217 +555,217 @@  discard block
 block discarded – undo
555 555
      * @param   Translate   $outputlangs    Object language for output
556 556
      * @return void
557 557
      */
558
-	private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
558
+    private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
559 559
     {
560
-		$pdf->SetDrawColor(128,128,128);
561
-		$posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2);
562
-		$posy = $tab_top + $tab_height + 3 + 3;
563
-
564
-		$pdf->SetXY($this->marge_gauche, $posy);
565
-		$pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0);
560
+        $pdf->SetDrawColor(128,128,128);
561
+        $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2);
562
+        $posy = $tab_top + $tab_height + 3 + 3;
566 563
 
567
-		$pdf->SetXY($this->marge_gauche, $posy + 5);
568
-		$pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1);
564
+        $pdf->SetXY($this->marge_gauche, $posy);
565
+        $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0);
569 566
 
570
-		$pdf->SetXY($posmiddle + 5, $posy);
571
-		$pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0);
567
+        $pdf->SetXY($this->marge_gauche, $posy + 5);
568
+        $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1);
572 569
 
573
-		$pdf->SetXY($posmiddle + 5, $posy + 5);
574
-		$pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1);
575
-	}
570
+        $pdf->SetXY($posmiddle + 5, $posy);
571
+        $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0);
576 572
 
577
-	/**
578
-	 *  Show top header of page.
579
-	 *
580
-	 *  @param	PDF			$pdf     		Object PDF
581
-	 *  @param  CommonObject		$object     	Object to show
582
-	 *  @param  int	    	$showaddress    0=no, 1=yes
583
-	 *  @param  Translate	$outputlangs	Object lang for output
584
-	 *  @return	void
585
-	 */
586
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
587
-	{
588
-		global $conf,$langs;
573
+        $pdf->SetXY($posmiddle + 5, $posy + 5);
574
+        $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1);
575
+    }
589 576
 
590
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
591
-
592
-		// Load traductions files requiredby by page
593
-		$outputlangs->loadLangs(array("main", "dict", "contract", "companies"));
594
-
595
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
596
-
597
-		//Affiche le filigrane brouillon - Print Draft Watermark
598
-		if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) )
599
-		{
600
-			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK);
601
-		}
602
-
603
-		//Prepare la suite
604
-		$pdf->SetTextColor(0,0,60);
605
-		$pdf->SetFont('','B', $default_font_size + 3);
606
-
607
-		$posx=$this->page_largeur-$this->marge_droite-100;
608
-		$posy=$this->marge_haute;
609
-
610
-		$pdf->SetXY($this->marge_gauche,$posy);
611
-
612
-		// Logo
613
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
614
-		if ($this->emetteur->logo)
615
-		{
616
-			if (is_readable($logo))
617
-			{
618
-			    $height=pdf_getHeightForLogo($logo);
619
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
620
-			}
621
-			else
622
-			{
623
-				$pdf->SetTextColor(200,0,0);
624
-				$pdf->SetFont('','B',$default_font_size - 2);
625
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
626
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
627
-			}
628
-		}
629
-		else
630
-		{
631
-			$text=$this->emetteur->name;
632
-			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
633
-		}
634
-
635
-		$pdf->SetFont('','B',$default_font_size + 3);
636
-		$pdf->SetXY($posx,$posy);
637
-		$pdf->SetTextColor(0,0,60);
638
-		$title=$outputlangs->transnoentities("ContractCard");
639
-		$pdf->MultiCell(100, 4, $title, '', 'R');
640
-
641
-		$pdf->SetFont('','B',$default_font_size + 2);
642
-
643
-		$posy+=5;
644
-		$pdf->SetXY($posx,$posy);
645
-		$pdf->SetTextColor(0,0,60);
646
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
647
-
648
-		$posy+=1;
649
-		$pdf->SetFont('','', $default_font_size);
650
-
651
-		$posy+=4;
652
-		$pdf->SetXY($posx,$posy);
653
-		$pdf->SetTextColor(0,0,60);
654
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R');
655
-
656
-		if ($object->thirdparty->code_client)
657
-		{
658
-			$posy+=4;
659
-			$pdf->SetXY($posx,$posy);
660
-			$pdf->SetTextColor(0,0,60);
661
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
662
-		}
663
-
664
-		if ($showaddress)
665
-		{
666
-			// Sender properties
667
-			$carac_emetteur='';
668
-			// Add internal contact of proposal if defined
669
-			$arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
670
-			if (count($arrayidcontact) > 0)
671
-			{
672
-				$object->fetch_user($arrayidcontact[0]);
673
-				$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
674
-			}
675
-
676
-			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
677
-
678
-			// Show sender
679
-			$posy=42;
680
-			$posx=$this->marge_gauche;
681
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
682
-			$hautcadre=40;
683
-
684
-			// Show sender frame
685
-			$pdf->SetTextColor(0,0,0);
686
-			$pdf->SetFont('','', $default_font_size - 2);
687
-			$pdf->SetXY($posx,$posy-5);
688
-			$pdf->SetXY($posx,$posy);
689
-			$pdf->SetFillColor(230,230,230);
690
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
691
-
692
-			// Show sender name
693
-			$pdf->SetXY($posx+2,$posy+3);
694
-			$pdf->SetTextColor(0,0,60);
695
-			$pdf->SetFont('','B',$default_font_size);
696
-			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
697
-			$posy=$pdf->getY();
698
-
699
-			// Show sender information
700
-			$pdf->SetFont('','', $default_font_size - 1);
701
-			$pdf->SetXY($posx+2,$posy);
702
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
703
-
704
-
705
-			// If CUSTOMER contact defined, we use it
706
-			$usecontact=false;
707
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
708
-			if (count($arrayidcontact) > 0)
709
-			{
710
-				$usecontact=true;
711
-				$result=$object->fetch_contact($arrayidcontact[0]);
712
-			}
713
-
714
-			$this->recipient = $object->thirdparty;
715
-
716
-			//Recipient name
717
-			// On peut utiliser le nom de la societe du contact
718
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
719
-				$thirdparty = $object->contact;
720
-			} else {
721
-				$thirdparty = $object->thirdparty;
722
-			}
723
-
724
-			$this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
725
-
726
-			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object);
727
-
728
-			// Show recipient
729
-			$widthrecbox=100;
730
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
731
-			$posy=42;
732
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
733
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
734
-
735
-			// Show recipient frame
736
-			$pdf->SetTextColor(0,0,0);
737
-			$pdf->SetFont('','', $default_font_size - 2);
738
-			$pdf->SetXY($posx+2,$posy-5);
739
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
740
-			$pdf->SetTextColor(0,0,0);
741
-
742
-			// Show recipient name
743
-			$pdf->SetXY($posx+2,$posy+3);
744
-			$pdf->SetFont('','B', $default_font_size);
745
-			$pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L');
746
-
747
-			$posy = $pdf->getY();
748
-
749
-			// Show recipient information
750
-			$pdf->SetFont('','', $default_font_size - 1);
751
-			$pdf->SetXY($posx+2,$posy);
752
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
753
-		}
754
-	}
577
+    /**
578
+     *  Show top header of page.
579
+     *
580
+     *  @param	PDF			$pdf     		Object PDF
581
+     *  @param  CommonObject		$object     	Object to show
582
+     *  @param  int	    	$showaddress    0=no, 1=yes
583
+     *  @param  Translate	$outputlangs	Object lang for output
584
+     *  @return	void
585
+     */
586
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
587
+    {
588
+        global $conf,$langs;
589
+
590
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
591
+
592
+        // Load traductions files requiredby by page
593
+        $outputlangs->loadLangs(array("main", "dict", "contract", "companies"));
594
+
595
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
596
+
597
+        //Affiche le filigrane brouillon - Print Draft Watermark
598
+        if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) )
599
+        {
600
+            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK);
601
+        }
602
+
603
+        //Prepare la suite
604
+        $pdf->SetTextColor(0,0,60);
605
+        $pdf->SetFont('','B', $default_font_size + 3);
606
+
607
+        $posx=$this->page_largeur-$this->marge_droite-100;
608
+        $posy=$this->marge_haute;
609
+
610
+        $pdf->SetXY($this->marge_gauche,$posy);
611
+
612
+        // Logo
613
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
614
+        if ($this->emetteur->logo)
615
+        {
616
+            if (is_readable($logo))
617
+            {
618
+                $height=pdf_getHeightForLogo($logo);
619
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
620
+            }
621
+            else
622
+            {
623
+                $pdf->SetTextColor(200,0,0);
624
+                $pdf->SetFont('','B',$default_font_size - 2);
625
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
626
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
627
+            }
628
+        }
629
+        else
630
+        {
631
+            $text=$this->emetteur->name;
632
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
633
+        }
634
+
635
+        $pdf->SetFont('','B',$default_font_size + 3);
636
+        $pdf->SetXY($posx,$posy);
637
+        $pdf->SetTextColor(0,0,60);
638
+        $title=$outputlangs->transnoentities("ContractCard");
639
+        $pdf->MultiCell(100, 4, $title, '', 'R');
640
+
641
+        $pdf->SetFont('','B',$default_font_size + 2);
642
+
643
+        $posy+=5;
644
+        $pdf->SetXY($posx,$posy);
645
+        $pdf->SetTextColor(0,0,60);
646
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
647
+
648
+        $posy+=1;
649
+        $pdf->SetFont('','', $default_font_size);
650
+
651
+        $posy+=4;
652
+        $pdf->SetXY($posx,$posy);
653
+        $pdf->SetTextColor(0,0,60);
654
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R');
655
+
656
+        if ($object->thirdparty->code_client)
657
+        {
658
+            $posy+=4;
659
+            $pdf->SetXY($posx,$posy);
660
+            $pdf->SetTextColor(0,0,60);
661
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
662
+        }
663
+
664
+        if ($showaddress)
665
+        {
666
+            // Sender properties
667
+            $carac_emetteur='';
668
+            // Add internal contact of proposal if defined
669
+            $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
670
+            if (count($arrayidcontact) > 0)
671
+            {
672
+                $object->fetch_user($arrayidcontact[0]);
673
+                $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
674
+            }
675
+
676
+            $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
677
+
678
+            // Show sender
679
+            $posy=42;
680
+            $posx=$this->marge_gauche;
681
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
682
+            $hautcadre=40;
683
+
684
+            // Show sender frame
685
+            $pdf->SetTextColor(0,0,0);
686
+            $pdf->SetFont('','', $default_font_size - 2);
687
+            $pdf->SetXY($posx,$posy-5);
688
+            $pdf->SetXY($posx,$posy);
689
+            $pdf->SetFillColor(230,230,230);
690
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
691
+
692
+            // Show sender name
693
+            $pdf->SetXY($posx+2,$posy+3);
694
+            $pdf->SetTextColor(0,0,60);
695
+            $pdf->SetFont('','B',$default_font_size);
696
+            $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
697
+            $posy=$pdf->getY();
698
+
699
+            // Show sender information
700
+            $pdf->SetFont('','', $default_font_size - 1);
701
+            $pdf->SetXY($posx+2,$posy);
702
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
703
+
704
+
705
+            // If CUSTOMER contact defined, we use it
706
+            $usecontact=false;
707
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
708
+            if (count($arrayidcontact) > 0)
709
+            {
710
+                $usecontact=true;
711
+                $result=$object->fetch_contact($arrayidcontact[0]);
712
+            }
713
+
714
+            $this->recipient = $object->thirdparty;
715
+
716
+            //Recipient name
717
+            // On peut utiliser le nom de la societe du contact
718
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
719
+                $thirdparty = $object->contact;
720
+            } else {
721
+                $thirdparty = $object->thirdparty;
722
+            }
723
+
724
+            $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
725
+
726
+            $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object);
727
+
728
+            // Show recipient
729
+            $widthrecbox=100;
730
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
731
+            $posy=42;
732
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
733
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
734
+
735
+            // Show recipient frame
736
+            $pdf->SetTextColor(0,0,0);
737
+            $pdf->SetFont('','', $default_font_size - 2);
738
+            $pdf->SetXY($posx+2,$posy-5);
739
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
740
+            $pdf->SetTextColor(0,0,0);
741
+
742
+            // Show recipient name
743
+            $pdf->SetXY($posx+2,$posy+3);
744
+            $pdf->SetFont('','B', $default_font_size);
745
+            $pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L');
746
+
747
+            $posy = $pdf->getY();
748
+
749
+            // Show recipient information
750
+            $pdf->SetFont('','', $default_font_size - 1);
751
+            $pdf->SetXY($posx+2,$posy);
752
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
753
+        }
754
+    }
755 755
 
756
-	/**
757
-	 *   	Show footer of page. Need this->emetteur object
756
+    /**
757
+     *   	Show footer of page. Need this->emetteur object
758 758
      *
759
-	 *   	@param	PDF			$pdf     			PDF
760
-	 * 		@param	CommonObject		$object				Object to show
761
-	 *      @param	Translate	$outputlangs		Object lang for output
762
-	 *      @param	int			$hidefreetext		1=Hide free text
763
-	 *      @return	integer
764
-	 */
765
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
766
-	{
767
-		global $conf;
768
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
769
-		return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
770
-	}
759
+     *   	@param	PDF			$pdf     			PDF
760
+     * 		@param	CommonObject		$object				Object to show
761
+     *      @param	Translate	$outputlangs		Object lang for output
762
+     *      @param	int			$hidefreetext		1=Hide free text
763
+     *      @return	integer
764
+     */
765
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
766
+    {
767
+        global $conf;
768
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
769
+        return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
770
+    }
771 771
 }
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	function __construct($db)
128 128
 	{
129
-		global $conf,$langs,$mysoc;
129
+		global $conf, $langs, $mysoc;
130 130
 
131 131
 		$this->db = $db;
132 132
 		$this->name = 'strato';
@@ -134,30 +134,30 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Dimension page pour format A4
136 136
 		$this->type = 'pdf';
137
-		$formatarray=pdf_getFormat();
137
+		$formatarray = pdf_getFormat();
138 138
 
139 139
 		$this->page_largeur = $formatarray['width'];
140 140
 		$this->page_hauteur = $formatarray['height'];
141
-		$this->format = array($this->page_largeur,$this->page_hauteur);
142
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
143
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
144
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
145
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
146
-
147
-		$this->option_logo = 1;                    // Affiche logo
148
-		$this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
149
-		$this->option_modereg = 0;                 // Affiche mode reglement
150
-		$this->option_condreg = 0;                 // Affiche conditions reglement
151
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
152
-		$this->option_multilang = 0;               // Dispo en plusieurs langues
153
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
141
+		$this->format = array($this->page_largeur, $this->page_hauteur);
142
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
143
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
144
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
145
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
146
+
147
+		$this->option_logo = 1; // Affiche logo
148
+		$this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
149
+		$this->option_modereg = 0; // Affiche mode reglement
150
+		$this->option_condreg = 0; // Affiche conditions reglement
151
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
152
+		$this->option_multilang = 0; // Dispo en plusieurs langues
153
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
154 154
 
155 155
 		// Get source company
156
-		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
156
+		$this->emetteur = $mysoc;
157
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined
158 158
 
159 159
 		// Define position of columns
160
-		$this->posxdesc=$this->marge_gauche+1;
160
+		$this->posxdesc = $this->marge_gauche + 1;
161 161
 	}
162 162
 
163 163
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
      *  @param		int				$hideref			Do not show ref
173 173
      *  @return		int									1=OK, 0=KO
174 174
 	 */
175
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
175
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
176 176
 	{
177 177
         // phpcs:enable
178
-		global $user,$langs,$conf,$hookmanager,$mysoc;
178
+		global $user, $langs, $conf, $hookmanager, $mysoc;
179 179
 
180
-		if (! is_object($outputlangs)) $outputlangs=$langs;
180
+		if (!is_object($outputlangs)) $outputlangs = $langs;
181 181
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
182
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
183 183
 
184 184
 		// Load traductions files requiredby by page
185 185
 		$outputlangs->loadLangs(array("main", "dict", "companies", "contracts"));
@@ -192,20 +192,20 @@  discard block
 block discarded – undo
192 192
 			if ($object->specimen)
193 193
 			{
194 194
 				$dir = $conf->contrat->dir_output;
195
-				$file = $dir . "/SPECIMEN.pdf";
195
+				$file = $dir."/SPECIMEN.pdf";
196 196
 			}
197 197
 			else
198 198
 			{
199 199
 				$objectref = dol_sanitizeFileName($object->ref);
200
-				$dir = $conf->contrat->dir_output . "/" . $objectref;
201
-				$file = $dir . "/" . $objectref . ".pdf";
200
+				$dir = $conf->contrat->dir_output."/".$objectref;
201
+				$file = $dir."/".$objectref.".pdf";
202 202
 			}
203 203
 
204
-			if (! file_exists($dir))
204
+			if (!file_exists($dir))
205 205
 			{
206 206
 				if (dol_mkdir($dir) < 0)
207 207
 				{
208
-					$this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
208
+					$this->error = $outputlangs->trans("ErrorCanNotCreateDir", $dir);
209 209
 					return 0;
210 210
 				}
211 211
 			}
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
 			if (file_exists($dir))
214 214
 			{
215 215
 				// Add pdfgeneration hook
216
-				if (! is_object($hookmanager))
216
+				if (!is_object($hookmanager))
217 217
 				{
218 218
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
219
-					$hookmanager=new HookManager($this->db);
219
+					$hookmanager = new HookManager($this->db);
220 220
 				}
221 221
 				$hookmanager->initHooks(array('pdfgeneration'));
222
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
222
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
223 223
 				global $action;
224
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
224
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
225 225
 
226
-                $pdf=pdf_getInstance($this->format);
227
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
228
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
229
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
230
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
231
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
232
-                $pdf->SetAutoPageBreak(1,0);
226
+                $pdf = pdf_getInstance($this->format);
227
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
228
+                $heightforinfotot = 50; // Height reserved to output the info and total part
229
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
230
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
231
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
232
+                $pdf->SetAutoPageBreak(1, 0);
233 233
 
234 234
                 if (class_exists('TCPDF'))
235 235
                 {
@@ -238,52 +238,52 @@  discard block
 block discarded – undo
238 238
                 }
239 239
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
240 240
                 // Set path to the background PDF File
241
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
241
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
242 242
                 {
243 243
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
244 244
                     $tplidx = $pdf->importPage(1);
245 245
                 }
246 246
 
247 247
 				$pdf->Open();
248
-				$pagenb=0;
249
-				$pdf->SetDrawColor(128,128,128);
248
+				$pagenb = 0;
249
+				$pdf->SetDrawColor(128, 128, 128);
250 250
 
251 251
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
252 252
 				$pdf->SetSubject($outputlangs->transnoentities("ContractCard"));
253 253
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
254 254
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
255 255
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
256
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
256
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
257 257
 
258
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
258
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
259 259
 
260 260
 				// New page
261 261
 				$pdf->AddPage();
262
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
262
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
263 263
 				$pagenb++;
264 264
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
265
-				$pdf->SetFont('','', $default_font_size - 1);
266
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
267
-				$pdf->SetTextColor(0,0,0);
265
+				$pdf->SetFont('', '', $default_font_size - 1);
266
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
267
+				$pdf->SetTextColor(0, 0, 0);
268 268
 
269 269
 				$tab_top = 90;
270
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
270
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
271 271
 
272 272
 				// Affiche notes
273
-				if (! empty($object->note_public))
273
+				if (!empty($object->note_public))
274 274
 				{
275 275
 					$tab_top -= 2;
276 276
 
277
-					$pdf->SetFont('','', $default_font_size - 1);
278
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
277
+					$pdf->SetFont('', '', $default_font_size - 1);
278
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1);
279 279
 					$nexY = $pdf->GetY();
280
-					$height_note=$nexY-$tab_top;
280
+					$height_note = $nexY - $tab_top;
281 281
 
282 282
 					// Rect prend une longueur en 3eme param
283
-					$pdf->SetDrawColor(192,192,192);
284
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
283
+					$pdf->SetDrawColor(192, 192, 192);
284
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
285 285
 
286
-					$tab_top = $nexY+6;
286
+					$tab_top = $nexY + 6;
287 287
 				}
288 288
 
289 289
 				$iniY = $tab_top + 7;
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 				$pdf->SetXY($this->marge_gauche, $tab_top);
294 294
 
295
-				$pdf->MultiCell(0, 2, '');		// Set interline to 3. Then writeMultiCell must use 3 also.
295
+				$pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
296 296
 
297 297
 				$nblines = count($object->lines);
298 298
 
@@ -305,44 +305,44 @@  discard block
 block discarded – undo
305 305
 
306 306
 					if ($valide > 0 || $object->specimen)
307 307
 					{
308
-						$curX = $this->posxdesc-1;
308
+						$curX = $this->posxdesc - 1;
309 309
 						$curY = $nexY;
310
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
311
-						$pdf->SetTextColor(0,0,0);
310
+						$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
311
+						$pdf->SetTextColor(0, 0, 0);
312 312
 
313 313
 						$pdf->setTopMargin($tab_top_newpage);
314
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
315
-						$pageposbefore=$pdf->getPage();
314
+						$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
315
+						$pageposbefore = $pdf->getPage();
316 316
 
317 317
 						// Description of product line
318 318
 
319 319
 						if ($objectligne->date_ouverture_prevue) {
320
-							$datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true);
320
+							$datei = dol_print_date($objectligne->date_ouverture_prevue, 'day', false, $outputlangs, true);
321 321
 						} else {
322 322
 							$datei = $langs->trans("Unknown");
323 323
 						}
324 324
 
325 325
 						if ($objectligne->date_fin_validite) {
326 326
 							$durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour');
327
-							$datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true);
327
+							$datee = dol_print_date($objectligne->date_fin_validite, 'day', false, $outputlangs, true);
328 328
 						} else {
329 329
 							$durationi = $langs->trans("Unknown");
330 330
 							$datee = $langs->trans("Unknown");
331 331
 						}
332 332
 
333 333
 						if ($objectligne->date_ouverture) {
334
-							$daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true);
334
+							$daters = dol_print_date($objectligne->date_ouverture, 'day', false, $outputlangs, true);
335 335
 						} else {
336 336
 							$daters = $langs->trans("Unknown");
337 337
 						}
338 338
 
339 339
 						if ($objectligne->date_cloture) {
340
-							$datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true);
340
+							$datere = dol_print_date($objectligne->date_cloture, 'day', false, $outputlangs, true);
341 341
 						} else {
342 342
 							$datere = $langs->trans("Unknown");
343 343
 						}
344 344
 
345
-						$txtpredefinedservice='';
345
+						$txtpredefinedservice = '';
346 346
                         $txtpredefinedservice = $objectligne->product_label;
347 347
                         if ($objectligne->product_label)
348 348
                         {
@@ -350,42 +350,42 @@  discard block
 block discarded – undo
350 350
                         	$txtpredefinedservice .= $objectligne->product_label;
351 351
                         }
352 352
 
353
-						$desc=dol_htmlentitiesbr($objectligne->desc,1);   // Desc (not empty for free lines)
354
-						$txt='';
355
-						$txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>';   // Desc (not empty for free lines)
356
-						$txt.='<br>';
357
-						$txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
358
-						$txt.='<br>';
359
-                        $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
360
-						if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
353
+						$desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines)
354
+						$txt = '';
355
+						$txt .= $outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines)
356
+						$txt .= '<br>';
357
+						$txt .= $outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
358
+						$txt .= '<br>';
359
+                        $txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
360
+						if ($objectligne->date_cloture) $txt .= " - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
361 361
 
362 362
 						$pdf->startTransaction();
363 363
 						$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
364
-						$pageposafter=$pdf->getPage();
364
+						$pageposafter = $pdf->getPage();
365 365
 						if ($pageposafter > $pageposbefore)	// There is a pagebreak
366 366
 						{
367 367
 							$pdf->rollbackTransaction(true);
368
-							$pageposafter=$pageposbefore;
368
+							$pageposafter = $pageposbefore;
369 369
 							//print $pageposafter.'-'.$pageposbefore;exit;
370
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
370
+							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
371 371
 							$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
372
-							$pageposafter=$pdf->getPage();
373
-							$posyafter=$pdf->GetY();
372
+							$pageposafter = $pdf->getPage();
373
+							$posyafter = $pdf->GetY();
374 374
 
375
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
375
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
376 376
 							{
377
-								if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
377
+								if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
378 378
 								{
379
-									$pdf->AddPage('','',true);
380
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
379
+									$pdf->AddPage('', '', true);
380
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
381 381
 									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
382
-									$pdf->setPage($pageposafter+1);
382
+									$pdf->setPage($pageposafter + 1);
383 383
 								}
384 384
 							}
385 385
 							else
386 386
 							{
387 387
 								// We found a page break
388
-								$showpricebeforepagebreak=0;
388
+								$showpricebeforepagebreak = 0;
389 389
 							}
390 390
 						}
391 391
 						else	// No pagebreak
@@ -394,18 +394,18 @@  discard block
 block discarded – undo
394 394
 						}
395 395
 
396 396
 						$nexY = $pdf->GetY() + 2;
397
-						$pageposafter=$pdf->getPage();
397
+						$pageposafter = $pdf->getPage();
398 398
 
399 399
 						$pdf->setPage($pageposbefore);
400 400
 						$pdf->setTopMargin($this->marge_haute);
401
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
401
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
402 402
 
403 403
 						// We suppose that a too long description is moved completely on next page
404 404
 						if ($pageposafter > $pageposbefore) {
405 405
 							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
406 406
 						}
407 407
 
408
-						$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
408
+						$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
409 409
 
410 410
 						// Detect if some page were added automatically and output _tableau for past pages
411 411
 						while ($pagenb < $pageposafter)
@@ -419,13 +419,13 @@  discard block
 block discarded – undo
419 419
 							{
420 420
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
421 421
 							}
422
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
422
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
423 423
 							$pagenb++;
424 424
 							$pdf->setPage($pagenb);
425
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
425
+							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
426 426
 						}
427 427
 
428
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
428
+						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
429 429
 						{
430 430
 							if ($pagenb == 1)
431 431
 							{
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 							{
436 436
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
437 437
 							}
438
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
438
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
439 439
 							// New page
440 440
 							$pdf->AddPage();
441
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
441
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
442 442
 							$pagenb++;
443 443
 						}
444 444
 					}
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 				{
450 450
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
451 451
 					$this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
452
-					$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
452
+					$bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfooter + 1;
453 453
 				}
454 454
 				else
455 455
 				{
456 456
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
457 457
 					$this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
458
-					$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
458
+					$bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfooter + 1;
459 459
 				}
460 460
 
461
-				$this->_pagefoot($pdf,$object,$outputlangs);
462
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
461
+				$this->_pagefoot($pdf, $object, $outputlangs);
462
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
463 463
 
464 464
 				$pdf->Close();
465 465
 
466
-				$pdf->Output($file,'F');
466
+				$pdf->Output($file, 'F');
467 467
 
468 468
 				// Add pdfgeneration hook
469
-				if (! is_object($hookmanager))
469
+				if (!is_object($hookmanager))
470 470
 				{
471 471
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
472
-					$hookmanager=new HookManager($this->db);
472
+					$hookmanager = new HookManager($this->db);
473 473
 				}
474 474
 				$hookmanager->initHooks(array('pdfgeneration'));
475
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
475
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
476 476
 				global $action;
477
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
477
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
478 478
 
479
-				if (! empty($conf->global->MAIN_UMASK))
479
+				if (!empty($conf->global->MAIN_UMASK))
480 480
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
481 481
 
482 482
 				$this->result = array('fullpath'=>$file);
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 			}
486 486
 			else
487 487
 			{
488
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
488
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
489 489
 				return 0;
490 490
 			}
491 491
 		}
492 492
 		else
493 493
 		{
494
-			$this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
494
+			$this->error = $langs->trans("ErrorConstantNotDefined", "CONTRACT_OUTPUTDIR");
495 495
 			return 0;
496 496
 		}
497 497
 	}
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
 	 *   @param		int			$hidebottom		Hide bottom bar of array
509 509
 	 *   @return	void
510 510
 	 */
511
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
511
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
512 512
 	{
513 513
 		global $conf;
514 514
 
515 515
 		// Force to disable hidetop and hidebottom
516
-		$hidebottom=0;
517
-		if ($hidetop) $hidetop=-1;
516
+		$hidebottom = 0;
517
+		if ($hidetop) $hidetop = -1;
518 518
 
519 519
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
520 520
 /*
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 */
545 545
 
546 546
 		// Output Rect
547
-		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3);	// Rect prend une longueur en 3eme param et 4eme param
547
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect prend une longueur en 3eme param et 4eme param
548 548
 	}
549 549
 
550 550
     /**
@@ -557,21 +557,21 @@  discard block
 block discarded – undo
557 557
      */
558 558
 	private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
559 559
     {
560
-		$pdf->SetDrawColor(128,128,128);
561
-		$posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2);
560
+		$pdf->SetDrawColor(128, 128, 128);
561
+		$posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2);
562 562
 		$posy = $tab_top + $tab_height + 3 + 3;
563 563
 
564 564
 		$pdf->SetXY($this->marge_gauche, $posy);
565
-		$pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0);
565
+		$pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name), 0, 'L', 0);
566 566
 
567 567
 		$pdf->SetXY($this->marge_gauche, $posy + 5);
568 568
 		$pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1);
569 569
 
570 570
 		$pdf->SetXY($posmiddle + 5, $posy);
571
-		$pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0);
571
+		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name), 0, 'L', 0);
572 572
 
573 573
 		$pdf->SetXY($posmiddle + 5, $posy + 5);
574
-		$pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1);
574
+		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1);
575 575
 	}
576 576
 
577 577
 	/**
@@ -585,130 +585,130 @@  discard block
 block discarded – undo
585 585
 	 */
586 586
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
587 587
 	{
588
-		global $conf,$langs;
588
+		global $conf, $langs;
589 589
 
590 590
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
591 591
 
592 592
 		// Load traductions files requiredby by page
593 593
 		$outputlangs->loadLangs(array("main", "dict", "contract", "companies"));
594 594
 
595
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
595
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
596 596
 
597 597
 		//Affiche le filigrane brouillon - Print Draft Watermark
598
-		if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) )
598
+		if ($object->statut == 0 && (!empty($conf->global->CONTRACT_DRAFT_WATERMARK)))
599 599
 		{
600
-			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK);
600
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->CONTRACT_DRAFT_WATERMARK);
601 601
 		}
602 602
 
603 603
 		//Prepare la suite
604
-		$pdf->SetTextColor(0,0,60);
605
-		$pdf->SetFont('','B', $default_font_size + 3);
604
+		$pdf->SetTextColor(0, 0, 60);
605
+		$pdf->SetFont('', 'B', $default_font_size + 3);
606 606
 
607
-		$posx=$this->page_largeur-$this->marge_droite-100;
608
-		$posy=$this->marge_haute;
607
+		$posx = $this->page_largeur - $this->marge_droite - 100;
608
+		$posy = $this->marge_haute;
609 609
 
610
-		$pdf->SetXY($this->marge_gauche,$posy);
610
+		$pdf->SetXY($this->marge_gauche, $posy);
611 611
 
612 612
 		// Logo
613
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
613
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
614 614
 		if ($this->emetteur->logo)
615 615
 		{
616 616
 			if (is_readable($logo))
617 617
 			{
618
-			    $height=pdf_getHeightForLogo($logo);
619
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
618
+			    $height = pdf_getHeightForLogo($logo);
619
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
620 620
 			}
621 621
 			else
622 622
 			{
623
-				$pdf->SetTextColor(200,0,0);
624
-				$pdf->SetFont('','B',$default_font_size - 2);
625
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
623
+				$pdf->SetTextColor(200, 0, 0);
624
+				$pdf->SetFont('', 'B', $default_font_size - 2);
625
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
626 626
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
627 627
 			}
628 628
 		}
629 629
 		else
630 630
 		{
631
-			$text=$this->emetteur->name;
631
+			$text = $this->emetteur->name;
632 632
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
633 633
 		}
634 634
 
635
-		$pdf->SetFont('','B',$default_font_size + 3);
636
-		$pdf->SetXY($posx,$posy);
637
-		$pdf->SetTextColor(0,0,60);
638
-		$title=$outputlangs->transnoentities("ContractCard");
635
+		$pdf->SetFont('', 'B', $default_font_size + 3);
636
+		$pdf->SetXY($posx, $posy);
637
+		$pdf->SetTextColor(0, 0, 60);
638
+		$title = $outputlangs->transnoentities("ContractCard");
639 639
 		$pdf->MultiCell(100, 4, $title, '', 'R');
640 640
 
641
-		$pdf->SetFont('','B',$default_font_size + 2);
641
+		$pdf->SetFont('', 'B', $default_font_size + 2);
642 642
 
643
-		$posy+=5;
644
-		$pdf->SetXY($posx,$posy);
645
-		$pdf->SetTextColor(0,0,60);
646
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
643
+		$posy += 5;
644
+		$pdf->SetXY($posx, $posy);
645
+		$pdf->SetTextColor(0, 0, 60);
646
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
647 647
 
648
-		$posy+=1;
649
-		$pdf->SetFont('','', $default_font_size);
648
+		$posy += 1;
649
+		$pdf->SetFont('', '', $default_font_size);
650 650
 
651
-		$posy+=4;
652
-		$pdf->SetXY($posx,$posy);
653
-		$pdf->SetTextColor(0,0,60);
654
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R');
651
+		$posy += 4;
652
+		$pdf->SetXY($posx, $posy);
653
+		$pdf->SetTextColor(0, 0, 60);
654
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_contrat, "day", false, $outputlangs, true), '', 'R');
655 655
 
656 656
 		if ($object->thirdparty->code_client)
657 657
 		{
658
-			$posy+=4;
659
-			$pdf->SetXY($posx,$posy);
660
-			$pdf->SetTextColor(0,0,60);
661
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
658
+			$posy += 4;
659
+			$pdf->SetXY($posx, $posy);
660
+			$pdf->SetTextColor(0, 0, 60);
661
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
662 662
 		}
663 663
 
664 664
 		if ($showaddress)
665 665
 		{
666 666
 			// Sender properties
667
-			$carac_emetteur='';
667
+			$carac_emetteur = '';
668 668
 			// Add internal contact of proposal if defined
669
-			$arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
669
+			$arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
670 670
 			if (count($arrayidcontact) > 0)
671 671
 			{
672 672
 				$object->fetch_user($arrayidcontact[0]);
673
-				$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
673
+				$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
674 674
 			}
675 675
 
676 676
 			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
677 677
 
678 678
 			// Show sender
679
-			$posy=42;
680
-			$posx=$this->marge_gauche;
681
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
682
-			$hautcadre=40;
679
+			$posy = 42;
680
+			$posx = $this->marge_gauche;
681
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
682
+			$hautcadre = 40;
683 683
 
684 684
 			// Show sender frame
685
-			$pdf->SetTextColor(0,0,0);
686
-			$pdf->SetFont('','', $default_font_size - 2);
687
-			$pdf->SetXY($posx,$posy-5);
688
-			$pdf->SetXY($posx,$posy);
689
-			$pdf->SetFillColor(230,230,230);
685
+			$pdf->SetTextColor(0, 0, 0);
686
+			$pdf->SetFont('', '', $default_font_size - 2);
687
+			$pdf->SetXY($posx, $posy - 5);
688
+			$pdf->SetXY($posx, $posy);
689
+			$pdf->SetFillColor(230, 230, 230);
690 690
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
691 691
 
692 692
 			// Show sender name
693
-			$pdf->SetXY($posx+2,$posy+3);
694
-			$pdf->SetTextColor(0,0,60);
695
-			$pdf->SetFont('','B',$default_font_size);
693
+			$pdf->SetXY($posx + 2, $posy + 3);
694
+			$pdf->SetTextColor(0, 0, 60);
695
+			$pdf->SetFont('', 'B', $default_font_size);
696 696
 			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
697
-			$posy=$pdf->getY();
697
+			$posy = $pdf->getY();
698 698
 
699 699
 			// Show sender information
700
-			$pdf->SetFont('','', $default_font_size - 1);
701
-			$pdf->SetXY($posx+2,$posy);
700
+			$pdf->SetFont('', '', $default_font_size - 1);
701
+			$pdf->SetXY($posx + 2, $posy);
702 702
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
703 703
 
704 704
 
705 705
 			// If CUSTOMER contact defined, we use it
706
-			$usecontact=false;
707
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
706
+			$usecontact = false;
707
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
708 708
 			if (count($arrayidcontact) > 0)
709 709
 			{
710
-				$usecontact=true;
711
-				$result=$object->fetch_contact($arrayidcontact[0]);
710
+				$usecontact = true;
711
+				$result = $object->fetch_contact($arrayidcontact[0]);
712 712
 			}
713 713
 
714 714
 			$this->recipient = $object->thirdparty;
@@ -723,32 +723,32 @@  discard block
 block discarded – undo
723 723
 
724 724
 			$this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
725 725
 
726
-			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object);
726
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), $usecontact, 'target', $object);
727 727
 
728 728
 			// Show recipient
729
-			$widthrecbox=100;
730
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
731
-			$posy=42;
732
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
733
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
729
+			$widthrecbox = 100;
730
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
731
+			$posy = 42;
732
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
733
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
734 734
 
735 735
 			// Show recipient frame
736
-			$pdf->SetTextColor(0,0,0);
737
-			$pdf->SetFont('','', $default_font_size - 2);
738
-			$pdf->SetXY($posx+2,$posy-5);
736
+			$pdf->SetTextColor(0, 0, 0);
737
+			$pdf->SetFont('', '', $default_font_size - 2);
738
+			$pdf->SetXY($posx + 2, $posy - 5);
739 739
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
740
-			$pdf->SetTextColor(0,0,0);
740
+			$pdf->SetTextColor(0, 0, 0);
741 741
 
742 742
 			// Show recipient name
743
-			$pdf->SetXY($posx+2,$posy+3);
744
-			$pdf->SetFont('','B', $default_font_size);
743
+			$pdf->SetXY($posx + 2, $posy + 3);
744
+			$pdf->SetFont('', 'B', $default_font_size);
745 745
 			$pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L');
746 746
 
747 747
 			$posy = $pdf->getY();
748 748
 
749 749
 			// Show recipient information
750
-			$pdf->SetFont('','', $default_font_size - 1);
751
-			$pdf->SetXY($posx+2,$posy);
750
+			$pdf->SetFont('', '', $default_font_size - 1);
751
+			$pdf->SetXY($posx + 2, $posy);
752 752
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
753 753
 		}
754 754
 	}
@@ -762,10 +762,10 @@  discard block
 block discarded – undo
762 762
 	 *      @param	int			$hidefreetext		1=Hide free text
763 763
 	 *      @return	integer
764 764
 	 */
765
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
765
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
766 766
 	{
767 767
 		global $conf;
768
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
769
-		return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
768
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
769
+		return pdf_pagefoot($pdf, $outputlangs, 'CONTRACT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
770 770
 	}
771 771
 }
Please login to merge, or discard this patch.
Braces   +66 added lines, -39 removed lines patch added patch discarded remove patch
@@ -154,7 +154,10 @@  discard block
 block discarded – undo
154 154
 
155 155
 		// Get source company
156 156
 		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
157
+		if (empty($this->emetteur->country_code)) {
158
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
159
+		}
160
+		// By default, if not defined
158 161
 
159 162
 		// Define position of columns
160 163
 		$this->posxdesc=$this->marge_gauche+1;
@@ -177,9 +180,13 @@  discard block
 block discarded – undo
177 180
         // phpcs:enable
178 181
 		global $user,$langs,$conf,$hookmanager,$mysoc;
179 182
 
180
-		if (! is_object($outputlangs)) $outputlangs=$langs;
183
+		if (! is_object($outputlangs)) {
184
+		    $outputlangs=$langs;
185
+		}
181 186
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
187
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
188
+		    $outputlangs->charset_output='ISO-8859-1';
189
+		}
183 190
 
184 191
 		// Load traductions files requiredby by page
185 192
 		$outputlangs->loadLangs(array("main", "dict", "companies", "contracts"));
@@ -193,8 +200,7 @@  discard block
 block discarded – undo
193 200
 			{
194 201
 				$dir = $conf->contrat->dir_output;
195 202
 				$file = $dir . "/SPECIMEN.pdf";
196
-			}
197
-			else
203
+			} else
198 204
 			{
199 205
 				$objectref = dol_sanitizeFileName($object->ref);
200 206
 				$dir = $conf->contrat->dir_output . "/" . $objectref;
@@ -228,7 +234,9 @@  discard block
 block discarded – undo
228 234
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
229 235
 		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
230 236
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
231
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
237
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
238
+	                $heightforfooter+= 6;
239
+	            }
232 240
                 $pdf->SetAutoPageBreak(1,0);
233 241
 
234 242
                 if (class_exists('TCPDF'))
@@ -253,13 +261,17 @@  discard block
 block discarded – undo
253 261
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
254 262
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
255 263
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
256
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
265
+				    $pdf->SetCompression(false);
266
+				}
257 267
 
258 268
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
259 269
 
260 270
 				// New page
261 271
 				$pdf->AddPage();
262
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
272
+				if (! empty($tplidx)) {
273
+				    $pdf->useTemplate($tplidx);
274
+				}
263 275
 				$pagenb++;
264 276
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
265 277
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -357,14 +369,18 @@  discard block
 block discarded – undo
357 369
 						$txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
358 370
 						$txt.='<br>';
359 371
                         $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
360
-						if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
372
+						if ($objectligne->date_cloture) {
373
+						    $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
374
+						}
361 375
 
362 376
 						$pdf->startTransaction();
363 377
 						$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
364 378
 						$pageposafter=$pdf->getPage();
365
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
379
+						if ($pageposafter > $pageposbefore) {
380
+						    // There is a pagebreak
366 381
 						{
367 382
 							$pdf->rollbackTransaction(true);
383
+						}
368 384
 							$pageposafter=$pageposbefore;
369 385
 							//print $pageposafter.'-'.$pageposbefore;exit;
370 386
 							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -372,23 +388,27 @@  discard block
 block discarded – undo
372 388
 							$pageposafter=$pdf->getPage();
373 389
 							$posyafter=$pdf->GetY();
374 390
 
375
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
391
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
392
+							    // There is no space left for total+free text
376 393
 							{
377 394
 								if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
378 395
 								{
379 396
 									$pdf->AddPage('','',true);
380
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
397
+							}
398
+									if (! empty($tplidx)) {
399
+									    $pdf->useTemplate($tplidx);
400
+									}
401
+									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
402
+									    $this->_pagehead($pdf, $object, 0, $outputlangs);
403
+									}
382 404
 									$pdf->setPage($pageposafter+1);
383 405
 								}
384
-							}
385
-							else
406
+							} else
386 407
 							{
387 408
 								// We found a page break
388 409
 								$showpricebeforepagebreak=0;
389 410
 							}
390
-						}
391
-						else	// No pagebreak
411
+						} else	// No pagebreak
392 412
 						{
393 413
 							$pdf->commitTransaction();
394 414
 						}
@@ -414,8 +434,7 @@  discard block
 block discarded – undo
414 434
 							if ($pagenb == 1)
415 435
 							{
416 436
 								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
417
-							}
418
-							else
437
+							} else
419 438
 							{
420 439
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
421 440
 							}
@@ -430,15 +449,16 @@  discard block
 block discarded – undo
430 449
 							if ($pagenb == 1)
431 450
 							{
432 451
 								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
433
-							}
434
-							else
452
+							} else
435 453
 							{
436 454
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
437 455
 							}
438 456
 							$this->_pagefoot($pdf,$object,$outputlangs,1);
439 457
 							// New page
440 458
 							$pdf->AddPage();
441
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
459
+							if (! empty($tplidx)) {
460
+							    $pdf->useTemplate($tplidx);
461
+							}
442 462
 							$pagenb++;
443 463
 						}
444 464
 					}
@@ -450,8 +470,7 @@  discard block
 block discarded – undo
450 470
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
451 471
 					$this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
452 472
 					$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
453
-				}
454
-				else
473
+				} else
455 474
 				{
456 475
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
457 476
 					$this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
@@ -459,7 +478,9 @@  discard block
 block discarded – undo
459 478
 				}
460 479
 
461 480
 				$this->_pagefoot($pdf,$object,$outputlangs);
462
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
481
+				if (method_exists($pdf,'AliasNbPages')) {
482
+				    $pdf->AliasNbPages();
483
+				}
463 484
 
464 485
 				$pdf->Close();
465 486
 
@@ -476,20 +497,19 @@  discard block
 block discarded – undo
476 497
 				global $action;
477 498
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
478 499
 
479
-				if (! empty($conf->global->MAIN_UMASK))
480
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
500
+				if (! empty($conf->global->MAIN_UMASK)) {
501
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
502
+				}
481 503
 
482 504
 				$this->result = array('fullpath'=>$file);
483 505
 
484 506
 				return 1;
485
-			}
486
-			else
507
+			} else
487 508
 			{
488 509
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
489 510
 				return 0;
490 511
 			}
491
-		}
492
-		else
512
+		} else
493 513
 		{
494 514
 			$this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
495 515
 			return 0;
@@ -514,7 +534,9 @@  discard block
 block discarded – undo
514 534
 
515 535
 		// Force to disable hidetop and hidebottom
516 536
 		$hidebottom=0;
517
-		if ($hidetop) $hidetop=-1;
537
+		if ($hidetop) {
538
+		    $hidetop=-1;
539
+		}
518 540
 
519 541
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
520 542
 /*
@@ -617,16 +639,14 @@  discard block
 block discarded – undo
617 639
 			{
618 640
 			    $height=pdf_getHeightForLogo($logo);
619 641
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
620
-			}
621
-			else
642
+			} else
622 643
 			{
623 644
 				$pdf->SetTextColor(200,0,0);
624 645
 				$pdf->SetFont('','B',$default_font_size - 2);
625 646
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
626 647
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
627 648
 			}
628
-		}
629
-		else
649
+		} else
630 650
 		{
631 651
 			$text=$this->emetteur->name;
632 652
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -678,7 +698,9 @@  discard block
 block discarded – undo
678 698
 			// Show sender
679 699
 			$posy=42;
680 700
 			$posx=$this->marge_gauche;
681
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
701
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
702
+			    $posx=$this->page_largeur-$this->marge_droite-80;
703
+			}
682 704
 			$hautcadre=40;
683 705
 
684 706
 			// Show sender frame
@@ -727,10 +749,15 @@  discard block
 block discarded – undo
727 749
 
728 750
 			// Show recipient
729 751
 			$widthrecbox=100;
730
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
752
+			if ($this->page_largeur < 210) {
753
+			    $widthrecbox=84;
754
+			}
755
+			// To work with US executive format
731 756
 			$posy=42;
732 757
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
733
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
758
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
759
+			    $posx=$this->marge_gauche;
760
+			}
734 761
 
735 762
 			// Show recipient frame
736 763
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php 3 patches
Indentation   +439 added lines, -439 removed lines patch added patch discarded remove patch
@@ -38,463 +38,463 @@
 block discarded – undo
38 38
  */
39 39
 class doc_generic_contract_odt extends ModelePDFContract
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
-	/**
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 54
      * Dolibarr version of the loaded document
55 55
      * @public string
56 56
      */
57
-	public $version = 'dolibarr';
57
+    public $version = 'dolibarr';
58 58
 
59 59
 
60
-	/**
61
-	 *	Constructor
62
-	 *
63
-	 *  @param		DoliDB		$db      Database handler
64
-	 */
65
-	function __construct($db)
66
-	{
67
-		global $conf, $langs, $mysoc;
60
+    /**
61
+     *	Constructor
62
+     *
63
+     *  @param		DoliDB		$db      Database handler
64
+     */
65
+    function __construct($db)
66
+    {
67
+        global $conf, $langs, $mysoc;
68 68
 
69
-		// Load translation files required by the page
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 = 'CONTRACT_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 CONTRACT_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 = 'CONTRACT_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 CONTRACT_TVAOPTION
89
+        $this->option_modereg = 0;                 // Affiche mode reglement
90
+        $this->option_condreg = 0;                 // Affiche conditions reglement
91
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
92
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
93
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
94
+        $this->option_credit_note = 0;             // Support credit notes
95
+        $this->option_freetext = 1;				   // Support add of a personalised text
96
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
+
98
+        // Recupere emetteur
99
+        $this->emetteur=$mysoc;
100
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+    }
102
+
103
+
104
+    /**
105
+     *	Return description of a module
106
+     *
107
+     *	@param	Translate	$langs      Lang object to use for output
108
+     *	@return string       			Description
109
+     */
110
+    function info($langs)
111
+    {
112
+        global $conf,$langs;
113
+
114
+        // Load translation files required by the page
115 115
         $langs->loadLangs(array('companies', 'errors'));
116 116
 
117
-		$form = new Form($this->db);
118
-
119
-		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
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="CONTRACT_ADDON_PDF_ODT_PATH">';
124
-		$texte.= '<table class="nobordernopadding" width="100%">';
125
-
126
-		// List of directories area
127
-		$texte.= '<tr><td>';
128
-		$texttitle=$langs->trans("ListOfDirectories");
129
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)));
130
-		$listoffiles=array();
131
-		foreach($listofdir as $key=>$tmpdir)
132
-		{
133
-			$tmpdir=trim($tmpdir);
134
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
135
-			if (! $tmpdir) {
136
-				unset($listofdir[$key]); continue;
137
-			}
138
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
139
-			else
140
-			{
141
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
142
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
143
-			}
144
-		}
145
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
146
-		// Add list of substitution keys
147
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
148
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
149
-
150
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
151
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
152
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
153
-		$texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
154
-		$texte.= '</textarea>';
155
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
156
-		$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
157
-		$texte.= '<br></div></div>';
158
-
159
-		// Scan directories
160
-		if (count($listofdir))
161
-		{
162
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
163
-		}
164
-
165
-		// Add select to upload a new template file. TODO Copy this feature on other admin pages.
166
-		$texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
167
-		$texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
168
-		$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
117
+        $form = new Form($this->db);
118
+
119
+        $texte = $this->description.".<br>\n";
120
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
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="CONTRACT_ADDON_PDF_ODT_PATH">';
124
+        $texte.= '<table class="nobordernopadding" width="100%">';
125
+
126
+        // List of directories area
127
+        $texte.= '<tr><td>';
128
+        $texttitle=$langs->trans("ListOfDirectories");
129
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)));
130
+        $listoffiles=array();
131
+        foreach($listofdir as $key=>$tmpdir)
132
+        {
133
+            $tmpdir=trim($tmpdir);
134
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
135
+            if (! $tmpdir) {
136
+                unset($listofdir[$key]); continue;
137
+            }
138
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
139
+            else
140
+            {
141
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
142
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
143
+            }
144
+        }
145
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
146
+        // Add list of substitution keys
147
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
148
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
149
+
150
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
151
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
152
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
153
+        $texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
154
+        $texte.= '</textarea>';
155
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
156
+        $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
157
+        $texte.= '<br></div></div>';
158
+
159
+        // Scan directories
160
+        if (count($listofdir))
161
+        {
162
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
163
+        }
164
+
165
+        // Add select to upload a new template file. TODO Copy this feature on other admin pages.
166
+        $texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
167
+        $texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
168
+        $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
169 169
         $texte.= '</div>';
170 170
 
171
-		$texte.= '</td>';
171
+        $texte.= '</td>';
172 172
 
173
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
174
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
175
-		$texte.= '</td>';
176
-		$texte.= '</tr>';
173
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
174
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
175
+        $texte.= '</td>';
176
+        $texte.= '</tr>';
177 177
 
178
-		$texte.= '</table>';
179
-		$texte.= '</form>';
178
+        $texte.= '</table>';
179
+        $texte.= '</form>';
180 180
 
181
-		return $texte;
182
-	}
181
+        return $texte;
182
+    }
183 183
 
184 184
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
185
-	/**
186
-	 *	Function to build a document on disk using the generic odt module.
187
-	 *
188
-	 *	@param		Contract		$object				Object source to build document
189
-	 *	@param		Translate	$outputlangs		Lang output object
190
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
191
-	 *  @param		int			$hidedetails		Do not show line details
192
-	 *  @param		int			$hidedesc			Do not show desc
193
-	 *  @param		int			$hideref			Do not show ref
194
-	 *	@return		int         					1 if OK, <=0 if KO
195
-	 */
196
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
197
-	{
185
+    /**
186
+     *	Function to build a document on disk using the generic odt module.
187
+     *
188
+     *	@param		Contract		$object				Object source to build document
189
+     *	@param		Translate	$outputlangs		Lang output object
190
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
191
+     *  @param		int			$hidedetails		Do not show line details
192
+     *  @param		int			$hidedesc			Do not show desc
193
+     *  @param		int			$hideref			Do not show ref
194
+     *	@return		int         					1 if OK, <=0 if KO
195
+     */
196
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
197
+    {
198 198
         // phpcs:enable
199
-		global $user,$langs,$conf,$mysoc,$hookmanager;
200
-
201
-		if (empty($srctemplatepath))
202
-		{
203
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
204
-			return -1;
205
-		}
206
-
207
-		// Add odtgeneration hook
208
-		if (! is_object($hookmanager))
209
-		{
210
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
211
-			$hookmanager=new HookManager($this->db);
212
-		}
213
-		$hookmanager->initHooks(array('odtgeneration'));
214
-		global $action;
215
-
216
-		if (! is_object($outputlangs)) $outputlangs=$langs;
217
-		$sav_charset_output=$outputlangs->charset_output;
218
-		$outputlangs->charset_output='UTF-8';
219
-
220
-		// Load traductions files requiredby by page
221
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
222
-
223
-		if ($conf->contrat->dir_output)
224
-		{
225
-			// If $object is id instead of object
226
-			if (! is_object($object))
227
-			{
228
-				$id = $object;
229
-				$object = new Contrat($this->db);
230
-				$result=$object->fetch($id);
231
-				if ($result < 0)
232
-				{
233
-					dol_print_error($this->db,$object->error);
234
-					return -1;
235
-				}
236
-			}
237
-
238
-			$dir = $conf->contrat->dir_output;
239
-			$objectref = dol_sanitizeFileName($object->ref);
240
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
241
-			$file = $dir . "/" . $objectref . ".odt";
242
-
243
-			if (! file_exists($dir))
244
-			{
245
-				if (dol_mkdir($dir) < 0)
246
-				{
247
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
248
-					return -1;
249
-				}
250
-			}
251
-
252
-			if (file_exists($dir))
253
-			{
254
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
255
-				$newfile=basename($srctemplatepath);
256
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
257
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
258
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
259
-
260
-				$newfiletmp=$objectref.'_'.$newfiletmp;
261
-
262
-				// Get extension (ods or odt)
263
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
264
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
265
-				{
266
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
267
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
268
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
269
-				}
270
-				else
271
-				{
272
-					$filename=$newfiletmp.'.'.$newfileformat;
273
-				}
274
-				$file=$dir.'/'.$filename;
275
-				//print "newdir=".$dir;
276
-				//print "newfile=".$newfile;
277
-				//print "file=".$file;
278
-				//print "conf->contrat->dir_temp=".$conf->contrat->dir_temp;
279
-
280
-				dol_mkdir($conf->contrat->dir_temp);
281
-
282
-
283
-				// If CUSTOMER contact defined on contract, we use it
284
-				$usecontact=false;
285
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
286
-				if (count($arrayidcontact) > 0)
287
-				{
288
-					$usecontact=true;
289
-					$result=$object->fetch_contact($arrayidcontact[0]);
290
-				}
291
-
292
-				// Recipient name
293
-				$contactobject=null;
294
-				if (! empty($usecontact))
295
-				{
296
-					// On peut utiliser le nom de la societe du contact
297
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
298
-					else {
299
-                        			$socobject = $object->thirdparty;
300
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
301
-                        			$contactobject = $object->contact;
302
-                    			}
303
-				}
304
-				else
305
-				{
306
-					$socobject=$object->thirdparty;
307
-				}
308
-
309
-				$object->fetch_optionals();
310
-
311
-
312
-				// Define substitution array
313
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
314
-				$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
315
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);		// complete with vars not set as properties by get_substitutionarray_each_var_object
316
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
317
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
318
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
319
-				$array_other=$this->get_substitutionarray_other($outputlangs);
320
-				// retrieve contact information for use in order as contact_xxx tags
321
-				$array_thirdparty_contact = array();
322
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
323
-
324
-				$substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
325
-				complete_substitutions_array($substitutionarray, $outputlangs, $object);
326
-
327
-				$tmparray = $substitutionarray;
328
-
329
-				// Call the ODTSubstitution hook
330
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
331
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
332
-
333
-				// Line of free text
334
-				$newfreetext='';
335
-				$paramfreetext='CONTRACT_FREE_TEXT';
336
-				if (! empty($conf->global->$paramfreetext))
337
-				{
338
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray);
339
-				}
340
-
341
-
342
-				// Open and load template
343
-				require_once ODTPHP_PATH.'odf.php';
344
-				try {
345
-					$odfHandler = new odf(
346
-						$srctemplatepath,
347
-						array(
348
-						'PATH_TO_TMP'	  => $conf->contrat->dir_temp,
349
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
350
-						'DELIMITER_LEFT'  => '{',
351
-						'DELIMITER_RIGHT' => '}'
352
-						)
353
-					);
354
-				}
355
-				catch(Exception $e)
356
-				{
357
-					$this->error=$e->getMessage();
358
-					dol_syslog($e->getMessage(), LOG_INFO);
359
-					return -1;
360
-				}
361
-				// After construction $odfHandler->contentXml contains content and
362
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
363
-				// [!-- BEGIN lines --]*[!-- END lines --]
364
-				//print html_entity_decode($odfHandler->__toString());
365
-				//print exit;
366
-
367
-
368
-				// Make substitutions into odt of freetext
369
-				try {
370
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
371
-				}
372
-				catch (OdfException $e)
373
-				{
374
-					dol_syslog($e->getMessage(), LOG_INFO);
375
-				}
376
-
377
-				foreach($tmparray as $key=>$value)
378
-				{
379
-					try {
380
-						if (preg_match('/logo$/',$key)) // Image
381
-						{
382
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
383
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
384
-						}
385
-						else    // Text
386
-						{
387
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
388
-						}
389
-					}
390
-					catch (OdfException $e)
391
-					{
199
+        global $user,$langs,$conf,$mysoc,$hookmanager;
200
+
201
+        if (empty($srctemplatepath))
202
+        {
203
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
204
+            return -1;
205
+        }
206
+
207
+        // Add odtgeneration hook
208
+        if (! is_object($hookmanager))
209
+        {
210
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
211
+            $hookmanager=new HookManager($this->db);
212
+        }
213
+        $hookmanager->initHooks(array('odtgeneration'));
214
+        global $action;
215
+
216
+        if (! is_object($outputlangs)) $outputlangs=$langs;
217
+        $sav_charset_output=$outputlangs->charset_output;
218
+        $outputlangs->charset_output='UTF-8';
219
+
220
+        // Load traductions files requiredby by page
221
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
222
+
223
+        if ($conf->contrat->dir_output)
224
+        {
225
+            // If $object is id instead of object
226
+            if (! is_object($object))
227
+            {
228
+                $id = $object;
229
+                $object = new Contrat($this->db);
230
+                $result=$object->fetch($id);
231
+                if ($result < 0)
232
+                {
233
+                    dol_print_error($this->db,$object->error);
234
+                    return -1;
235
+                }
236
+            }
237
+
238
+            $dir = $conf->contrat->dir_output;
239
+            $objectref = dol_sanitizeFileName($object->ref);
240
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
241
+            $file = $dir . "/" . $objectref . ".odt";
242
+
243
+            if (! file_exists($dir))
244
+            {
245
+                if (dol_mkdir($dir) < 0)
246
+                {
247
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
248
+                    return -1;
249
+                }
250
+            }
251
+
252
+            if (file_exists($dir))
253
+            {
254
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
255
+                $newfile=basename($srctemplatepath);
256
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
257
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
258
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
259
+
260
+                $newfiletmp=$objectref.'_'.$newfiletmp;
261
+
262
+                // Get extension (ods or odt)
263
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
264
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
265
+                {
266
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
267
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
268
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
269
+                }
270
+                else
271
+                {
272
+                    $filename=$newfiletmp.'.'.$newfileformat;
273
+                }
274
+                $file=$dir.'/'.$filename;
275
+                //print "newdir=".$dir;
276
+                //print "newfile=".$newfile;
277
+                //print "file=".$file;
278
+                //print "conf->contrat->dir_temp=".$conf->contrat->dir_temp;
279
+
280
+                dol_mkdir($conf->contrat->dir_temp);
281
+
282
+
283
+                // If CUSTOMER contact defined on contract, we use it
284
+                $usecontact=false;
285
+                $arrayidcontact=$object->getIdContact('external','CUSTOMER');
286
+                if (count($arrayidcontact) > 0)
287
+                {
288
+                    $usecontact=true;
289
+                    $result=$object->fetch_contact($arrayidcontact[0]);
290
+                }
291
+
292
+                // Recipient name
293
+                $contactobject=null;
294
+                if (! empty($usecontact))
295
+                {
296
+                    // On peut utiliser le nom de la societe du contact
297
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
298
+                    else {
299
+                                    $socobject = $object->thirdparty;
300
+                                    // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
301
+                                    $contactobject = $object->contact;
302
+                                }
303
+                }
304
+                else
305
+                {
306
+                    $socobject=$object->thirdparty;
307
+                }
308
+
309
+                $object->fetch_optionals();
310
+
311
+
312
+                // Define substitution array
313
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
314
+                $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
315
+                $array_objet=$this->get_substitutionarray_object($object,$outputlangs);		// complete with vars not set as properties by get_substitutionarray_each_var_object
316
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
317
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
318
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
319
+                $array_other=$this->get_substitutionarray_other($outputlangs);
320
+                // retrieve contact information for use in order as contact_xxx tags
321
+                $array_thirdparty_contact = array();
322
+                if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
323
+
324
+                $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
325
+                complete_substitutions_array($substitutionarray, $outputlangs, $object);
326
+
327
+                $tmparray = $substitutionarray;
328
+
329
+                // Call the ODTSubstitution hook
330
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
331
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
332
+
333
+                // Line of free text
334
+                $newfreetext='';
335
+                $paramfreetext='CONTRACT_FREE_TEXT';
336
+                if (! empty($conf->global->$paramfreetext))
337
+                {
338
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray);
339
+                }
340
+
341
+
342
+                // Open and load template
343
+                require_once ODTPHP_PATH.'odf.php';
344
+                try {
345
+                    $odfHandler = new odf(
346
+                        $srctemplatepath,
347
+                        array(
348
+                        'PATH_TO_TMP'	  => $conf->contrat->dir_temp,
349
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
350
+                        'DELIMITER_LEFT'  => '{',
351
+                        'DELIMITER_RIGHT' => '}'
352
+                        )
353
+                    );
354
+                }
355
+                catch(Exception $e)
356
+                {
357
+                    $this->error=$e->getMessage();
358
+                    dol_syslog($e->getMessage(), LOG_INFO);
359
+                    return -1;
360
+                }
361
+                // After construction $odfHandler->contentXml contains content and
362
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
363
+                // [!-- BEGIN lines --]*[!-- END lines --]
364
+                //print html_entity_decode($odfHandler->__toString());
365
+                //print exit;
366
+
367
+
368
+                // Make substitutions into odt of freetext
369
+                try {
370
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
371
+                }
372
+                catch (OdfException $e)
373
+                {
374
+                    dol_syslog($e->getMessage(), LOG_INFO);
375
+                }
376
+
377
+                foreach($tmparray as $key=>$value)
378
+                {
379
+                    try {
380
+                        if (preg_match('/logo$/',$key)) // Image
381
+                        {
382
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
383
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
384
+                        }
385
+                        else    // Text
386
+                        {
387
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
388
+                        }
389
+                    }
390
+                    catch (OdfException $e)
391
+                    {
392
+                        dol_syslog($e->getMessage(), LOG_INFO);
393
+                    }
394
+                }
395
+
396
+                // Replace tags of lines
397
+                try
398
+                {
399
+                    $foundtagforlines = 1;
400
+                    try {
401
+                        $listlines = $odfHandler->setSegment('lines');
402
+                    }
403
+                    catch(OdfException $e)
404
+                    {
405
+                        // We may arrive here if tags for lines not present into template
406
+                        $foundtagforlines = 0;
392 407
                         dol_syslog($e->getMessage(), LOG_INFO);
393
-					}
394
-				}
395
-
396
-				// Replace tags of lines
397
-				try
398
-				{
399
-					$foundtagforlines = 1;
400
-					try {
401
-						$listlines = $odfHandler->setSegment('lines');
402
-					}
403
-					catch(OdfException $e)
404
-					{
405
-						// We may arrive here if tags for lines not present into template
406
-						$foundtagforlines = 0;
407
-						dol_syslog($e->getMessage(), LOG_INFO);
408
-					}
409
-					if ($foundtagforlines)
410
-					{
411
-						foreach ($object->lines as $line)
412
-						{
413
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
414
-							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
415
-							// Call the ODTSubstitutionLine hook
416
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
417
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
418
-							foreach($tmparray as $key => $val)
419
-							{
420
-								try
421
-								{
422
-									$listlines->setVars($key, $val, true, 'UTF-8');
423
-								}
424
-								catch(OdfException $e)
425
-								{
426
-									dol_syslog($e->getMessage(), LOG_INFO);
427
-								}
428
-								catch(SegmentException $e)
429
-								{
430
-									dol_syslog($e->getMessage(), LOG_INFO);
431
-								}
432
-							}
433
-							$listlines->merge();
434
-						}
435
-						$odfHandler->mergeSegment($listlines);
436
-					}
437
-				}
438
-				catch(OdfException $e)
439
-				{
440
-					$this->error=$e->getMessage();
441
-					dol_syslog($this->error, LOG_WARNING);
442
-					return -1;
443
-				}
444
-
445
-				// Replace labels translated
446
-				$tmparray=$outputlangs->get_translations_for_substitutions();
447
-				foreach($tmparray as $key=>$value)
448
-				{
449
-					try {
450
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
451
-					}
452
-					catch(OdfException $e)
453
-					{
408
+                    }
409
+                    if ($foundtagforlines)
410
+                    {
411
+                        foreach ($object->lines as $line)
412
+                        {
413
+                            $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
414
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
415
+                            // Call the ODTSubstitutionLine hook
416
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
417
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
418
+                            foreach($tmparray as $key => $val)
419
+                            {
420
+                                try
421
+                                {
422
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
423
+                                }
424
+                                catch(OdfException $e)
425
+                                {
426
+                                    dol_syslog($e->getMessage(), LOG_INFO);
427
+                                }
428
+                                catch(SegmentException $e)
429
+                                {
430
+                                    dol_syslog($e->getMessage(), LOG_INFO);
431
+                                }
432
+                            }
433
+                            $listlines->merge();
434
+                        }
435
+                        $odfHandler->mergeSegment($listlines);
436
+                    }
437
+                }
438
+                catch(OdfException $e)
439
+                {
440
+                    $this->error=$e->getMessage();
441
+                    dol_syslog($this->error, LOG_WARNING);
442
+                    return -1;
443
+                }
444
+
445
+                // Replace labels translated
446
+                $tmparray=$outputlangs->get_translations_for_substitutions();
447
+                foreach($tmparray as $key=>$value)
448
+                {
449
+                    try {
450
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
451
+                    }
452
+                    catch(OdfException $e)
453
+                    {
454 454
                         dol_syslog($e->getMessage(), LOG_INFO);
455
-					}
456
-				}
457
-
458
-				// Call the beforeODTSave hook
459
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
460
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
461
-
462
-				// Write new file
463
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
464
-					try {
465
-						$odfHandler->exportAsAttachedPDF($file);
466
-					} catch (Exception $e) {
467
-						$this->error=$e->getMessage();
468
-						return -1;
469
-					}
470
-				}
471
-				else {
472
-					try {
473
-					$odfHandler->saveToDisk($file);
474
-					} catch (Exception $e) {
475
-						$this->error=$e->getMessage();
476
-						return -1;
477
-					}
478
-				}
479
-
480
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
481
-
482
-				if (! empty($conf->global->MAIN_UMASK))
483
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
484
-
485
-				$odfHandler=null;	// Destroy object
486
-
487
-				$this->result = array('fullpath'=>$file);
488
-
489
-				return 1;   // Success
490
-			}
491
-			else
492
-			{
493
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
494
-				return -1;
495
-			}
496
-		}
497
-
498
-		return -1;
499
-	}
455
+                    }
456
+                }
457
+
458
+                // Call the beforeODTSave hook
459
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
460
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
461
+
462
+                // Write new file
463
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
464
+                    try {
465
+                        $odfHandler->exportAsAttachedPDF($file);
466
+                    } catch (Exception $e) {
467
+                        $this->error=$e->getMessage();
468
+                        return -1;
469
+                    }
470
+                }
471
+                else {
472
+                    try {
473
+                    $odfHandler->saveToDisk($file);
474
+                    } catch (Exception $e) {
475
+                        $this->error=$e->getMessage();
476
+                        return -1;
477
+                    }
478
+                }
479
+
480
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
481
+
482
+                if (! empty($conf->global->MAIN_UMASK))
483
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
484
+
485
+                $odfHandler=null;	// Destroy object
486
+
487
+                $this->result = array('fullpath'=>$file);
488
+
489
+                return 1;   // Success
490
+            }
491
+            else
492
+            {
493
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
494
+                return -1;
495
+            }
496
+        }
497
+
498
+        return -1;
499
+    }
500 500
 }
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 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 = 'CONTRACT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
75
+		$this->scandir = 'CONTRACT_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 CONTRACT_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 CONTRACT_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,7 +109,7 @@  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 115
         $langs->loadLangs(array('companies', 'errors'));
@@ -117,66 +117,66 @@  discard block
 block discarded – undo
117 117
 		$form = new Form($this->db);
118 118
 
119 119
 		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
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="CONTRACT_ADDON_PDF_ODT_PATH">';
124
-		$texte.= '<table class="nobordernopadding" width="100%">';
120
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
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="CONTRACT_ADDON_PDF_ODT_PATH">';
124
+		$texte .= '<table class="nobordernopadding" width="100%">';
125 125
 
126 126
 		// List of directories area
127
-		$texte.= '<tr><td>';
128
-		$texttitle=$langs->trans("ListOfDirectories");
129
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)));
130
-		$listoffiles=array();
131
-		foreach($listofdir as $key=>$tmpdir)
127
+		$texte .= '<tr><td>';
128
+		$texttitle = $langs->trans("ListOfDirectories");
129
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)));
130
+		$listoffiles = array();
131
+		foreach ($listofdir as $key=>$tmpdir)
132 132
 		{
133
-			$tmpdir=trim($tmpdir);
134
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
135
-			if (! $tmpdir) {
133
+			$tmpdir = trim($tmpdir);
134
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
135
+			if (!$tmpdir) {
136 136
 				unset($listofdir[$key]); continue;
137 137
 			}
138
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
138
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
139 139
 			else
140 140
 			{
141
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
142
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
141
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
142
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
143 143
 			}
144 144
 		}
145
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
145
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
146 146
 		// Add list of substitution keys
147
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
148
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
149
-
150
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
151
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
152
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
153
-		$texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
154
-		$texte.= '</textarea>';
155
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
156
-		$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
157
-		$texte.= '<br></div></div>';
147
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
148
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
149
+
150
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
151
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
152
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
153
+		$texte .= $conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
154
+		$texte .= '</textarea>';
155
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
156
+		$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
157
+		$texte .= '<br></div></div>';
158 158
 
159 159
 		// Scan directories
160 160
 		if (count($listofdir))
161 161
 		{
162
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
162
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
163 163
 		}
164 164
 
165 165
 		// Add select to upload a new template file. TODO Copy this feature on other admin pages.
166
-		$texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
167
-		$texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
168
-		$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
169
-        $texte.= '</div>';
166
+		$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
167
+		$texte .= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
168
+		$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
169
+        $texte .= '</div>';
170 170
 
171
-		$texte.= '</td>';
171
+		$texte .= '</td>';
172 172
 
173
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
174
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
175
-		$texte.= '</td>';
176
-		$texte.= '</tr>';
173
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
174
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
175
+		$texte .= '</td>';
176
+		$texte .= '</tr>';
177 177
 
178
-		$texte.= '</table>';
179
-		$texte.= '</form>';
178
+		$texte .= '</table>';
179
+		$texte .= '</form>';
180 180
 
181 181
 		return $texte;
182 182
 	}
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 	 *  @param		int			$hideref			Do not show ref
194 194
 	 *	@return		int         					1 if OK, <=0 if KO
195 195
 	 */
196
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
196
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
197 197
 	{
198 198
         // phpcs:enable
199
-		global $user,$langs,$conf,$mysoc,$hookmanager;
199
+		global $user, $langs, $conf, $mysoc, $hookmanager;
200 200
 
201 201
 		if (empty($srctemplatepath))
202 202
 		{
@@ -205,17 +205,17 @@  discard block
 block discarded – undo
205 205
 		}
206 206
 
207 207
 		// Add odtgeneration hook
208
-		if (! is_object($hookmanager))
208
+		if (!is_object($hookmanager))
209 209
 		{
210 210
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
211
-			$hookmanager=new HookManager($this->db);
211
+			$hookmanager = new HookManager($this->db);
212 212
 		}
213 213
 		$hookmanager->initHooks(array('odtgeneration'));
214 214
 		global $action;
215 215
 
216
-		if (! is_object($outputlangs)) $outputlangs=$langs;
217
-		$sav_charset_output=$outputlangs->charset_output;
218
-		$outputlangs->charset_output='UTF-8';
216
+		if (!is_object($outputlangs)) $outputlangs = $langs;
217
+		$sav_charset_output = $outputlangs->charset_output;
218
+		$outputlangs->charset_output = 'UTF-8';
219 219
 
220 220
 		// Load traductions files requiredby by page
221 221
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@@ -223,28 +223,28 @@  discard block
 block discarded – undo
223 223
 		if ($conf->contrat->dir_output)
224 224
 		{
225 225
 			// If $object is id instead of object
226
-			if (! is_object($object))
226
+			if (!is_object($object))
227 227
 			{
228 228
 				$id = $object;
229 229
 				$object = new Contrat($this->db);
230
-				$result=$object->fetch($id);
230
+				$result = $object->fetch($id);
231 231
 				if ($result < 0)
232 232
 				{
233
-					dol_print_error($this->db,$object->error);
233
+					dol_print_error($this->db, $object->error);
234 234
 					return -1;
235 235
 				}
236 236
 			}
237 237
 
238 238
 			$dir = $conf->contrat->dir_output;
239 239
 			$objectref = dol_sanitizeFileName($object->ref);
240
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
241
-			$file = $dir . "/" . $objectref . ".odt";
240
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
241
+			$file = $dir."/".$objectref.".odt";
242 242
 
243
-			if (! file_exists($dir))
243
+			if (!file_exists($dir))
244 244
 			{
245 245
 				if (dol_mkdir($dir) < 0)
246 246
 				{
247
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
247
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
248 248
 					return -1;
249 249
 				}
250 250
 			}
@@ -252,26 +252,26 @@  discard block
 block discarded – undo
252 252
 			if (file_exists($dir))
253 253
 			{
254 254
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
255
-				$newfile=basename($srctemplatepath);
256
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
257
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
258
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
255
+				$newfile = basename($srctemplatepath);
256
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
257
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
258
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
259 259
 
260
-				$newfiletmp=$objectref.'_'.$newfiletmp;
260
+				$newfiletmp = $objectref.'_'.$newfiletmp;
261 261
 
262 262
 				// Get extension (ods or odt)
263
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
264
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
263
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
264
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
265 265
 				{
266
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
267
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
268
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
266
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
267
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
268
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
269 269
 				}
270 270
 				else
271 271
 				{
272
-					$filename=$newfiletmp.'.'.$newfileformat;
272
+					$filename = $newfiletmp.'.'.$newfileformat;
273 273
 				}
274
-				$file=$dir.'/'.$filename;
274
+				$file = $dir.'/'.$filename;
275 275
 				//print "newdir=".$dir;
276 276
 				//print "newfile=".$newfile;
277 277
 				//print "file=".$file;
@@ -281,20 +281,20 @@  discard block
 block discarded – undo
281 281
 
282 282
 
283 283
 				// If CUSTOMER contact defined on contract, we use it
284
-				$usecontact=false;
285
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
284
+				$usecontact = false;
285
+				$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
286 286
 				if (count($arrayidcontact) > 0)
287 287
 				{
288
-					$usecontact=true;
289
-					$result=$object->fetch_contact($arrayidcontact[0]);
288
+					$usecontact = true;
289
+					$result = $object->fetch_contact($arrayidcontact[0]);
290 290
 				}
291 291
 
292 292
 				// Recipient name
293
-				$contactobject=null;
294
-				if (! empty($usecontact))
293
+				$contactobject = null;
294
+				if (!empty($usecontact))
295 295
 				{
296 296
 					// On peut utiliser le nom de la societe du contact
297
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
297
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
298 298
 					else {
299 299
                         			$socobject = $object->thirdparty;
300 300
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 				}
304 304
 				else
305 305
 				{
306
-					$socobject=$object->thirdparty;
306
+					$socobject = $object->thirdparty;
307 307
 				}
308 308
 
309 309
 				$object->fetch_optionals();
@@ -311,31 +311,31 @@  discard block
 block discarded – undo
311 311
 
312 312
 				// Define substitution array
313 313
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
314
-				$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
315
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);		// complete with vars not set as properties by get_substitutionarray_each_var_object
316
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
317
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
318
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
319
-				$array_other=$this->get_substitutionarray_other($outputlangs);
314
+				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
315
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object
316
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
317
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
318
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
319
+				$array_other = $this->get_substitutionarray_other($outputlangs);
320 320
 				// retrieve contact information for use in order as contact_xxx tags
321 321
 				$array_thirdparty_contact = array();
322
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
322
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
323 323
 
324
-				$substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
324
+				$substitutionarray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
325 325
 				complete_substitutions_array($substitutionarray, $outputlangs, $object);
326 326
 
327 327
 				$tmparray = $substitutionarray;
328 328
 
329 329
 				// Call the ODTSubstitution hook
330
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
331
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
330
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
331
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
332 332
 
333 333
 				// Line of free text
334
-				$newfreetext='';
335
-				$paramfreetext='CONTRACT_FREE_TEXT';
336
-				if (! empty($conf->global->$paramfreetext))
334
+				$newfreetext = '';
335
+				$paramfreetext = 'CONTRACT_FREE_TEXT';
336
+				if (!empty($conf->global->$paramfreetext))
337 337
 				{
338
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray);
338
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $tmparray);
339 339
 				}
340 340
 
341 341
 
@@ -346,15 +346,15 @@  discard block
 block discarded – undo
346 346
 						$srctemplatepath,
347 347
 						array(
348 348
 						'PATH_TO_TMP'	  => $conf->contrat->dir_temp,
349
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
349
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
350 350
 						'DELIMITER_LEFT'  => '{',
351 351
 						'DELIMITER_RIGHT' => '}'
352 352
 						)
353 353
 					);
354 354
 				}
355
-				catch(Exception $e)
355
+				catch (Exception $e)
356 356
 				{
357
-					$this->error=$e->getMessage();
357
+					$this->error = $e->getMessage();
358 358
 					dol_syslog($e->getMessage(), LOG_INFO);
359 359
 					return -1;
360 360
 				}
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 					dol_syslog($e->getMessage(), LOG_INFO);
375 375
 				}
376 376
 
377
-				foreach($tmparray as $key=>$value)
377
+				foreach ($tmparray as $key=>$value)
378 378
 				{
379 379
 					try {
380
-						if (preg_match('/logo$/',$key)) // Image
380
+						if (preg_match('/logo$/', $key)) // Image
381 381
 						{
382 382
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
383 383
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 					try {
401 401
 						$listlines = $odfHandler->setSegment('lines');
402 402
 					}
403
-					catch(OdfException $e)
403
+					catch (OdfException $e)
404 404
 					{
405 405
 						// We may arrive here if tags for lines not present into template
406 406
 						$foundtagforlines = 0;
@@ -410,22 +410,22 @@  discard block
 block discarded – undo
410 410
 					{
411 411
 						foreach ($object->lines as $line)
412 412
 						{
413
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
413
+							$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
414 414
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
415 415
 							// Call the ODTSubstitutionLine hook
416
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
417
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
418
-							foreach($tmparray as $key => $val)
416
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
417
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
418
+							foreach ($tmparray as $key => $val)
419 419
 							{
420 420
 								try
421 421
 								{
422 422
 									$listlines->setVars($key, $val, true, 'UTF-8');
423 423
 								}
424
-								catch(OdfException $e)
424
+								catch (OdfException $e)
425 425
 								{
426 426
 									dol_syslog($e->getMessage(), LOG_INFO);
427 427
 								}
428
-								catch(SegmentException $e)
428
+								catch (SegmentException $e)
429 429
 								{
430 430
 									dol_syslog($e->getMessage(), LOG_INFO);
431 431
 								}
@@ -435,36 +435,36 @@  discard block
 block discarded – undo
435 435
 						$odfHandler->mergeSegment($listlines);
436 436
 					}
437 437
 				}
438
-				catch(OdfException $e)
438
+				catch (OdfException $e)
439 439
 				{
440
-					$this->error=$e->getMessage();
440
+					$this->error = $e->getMessage();
441 441
 					dol_syslog($this->error, LOG_WARNING);
442 442
 					return -1;
443 443
 				}
444 444
 
445 445
 				// Replace labels translated
446
-				$tmparray=$outputlangs->get_translations_for_substitutions();
447
-				foreach($tmparray as $key=>$value)
446
+				$tmparray = $outputlangs->get_translations_for_substitutions();
447
+				foreach ($tmparray as $key=>$value)
448 448
 				{
449 449
 					try {
450 450
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
451 451
 					}
452
-					catch(OdfException $e)
452
+					catch (OdfException $e)
453 453
 					{
454 454
                         dol_syslog($e->getMessage(), LOG_INFO);
455 455
 					}
456 456
 				}
457 457
 
458 458
 				// Call the beforeODTSave hook
459
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
460
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
459
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
460
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
461 461
 
462 462
 				// Write new file
463 463
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
464 464
 					try {
465 465
 						$odfHandler->exportAsAttachedPDF($file);
466 466
 					} catch (Exception $e) {
467
-						$this->error=$e->getMessage();
467
+						$this->error = $e->getMessage();
468 468
 						return -1;
469 469
 					}
470 470
 				}
@@ -472,25 +472,25 @@  discard block
 block discarded – undo
472 472
 					try {
473 473
 					$odfHandler->saveToDisk($file);
474 474
 					} catch (Exception $e) {
475
-						$this->error=$e->getMessage();
475
+						$this->error = $e->getMessage();
476 476
 						return -1;
477 477
 					}
478 478
 				}
479 479
 
480
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
480
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
481 481
 
482
-				if (! empty($conf->global->MAIN_UMASK))
482
+				if (!empty($conf->global->MAIN_UMASK))
483 483
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
484 484
 
485
-				$odfHandler=null;	// Destroy object
485
+				$odfHandler = null; // Destroy object
486 486
 
487 487
 				$this->result = array('fullpath'=>$file);
488 488
 
489
-				return 1;   // Success
489
+				return 1; // Success
490 490
 			}
491 491
 			else
492 492
 			{
493
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
493
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
494 494
 				return -1;
495 495
 			}
496 496
 		}
Please login to merge, or discard this patch.
Braces   +46 added lines, -40 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
 
@@ -135,11 +138,14 @@  discard block
 block discarded – undo
135 138
 			if (! $tmpdir) {
136 139
 				unset($listofdir[$key]); continue;
137 140
 			}
138
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
139
-			else
141
+			if (! is_dir($tmpdir)) {
142
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
143
+			} else
140 144
 			{
141 145
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
142
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
146
+				if (count($tmpfiles)) {
147
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
148
+				}
143 149
 			}
144 150
 		}
145 151
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -213,7 +219,9 @@  discard block
 block discarded – undo
213 219
 		$hookmanager->initHooks(array('odtgeneration'));
214 220
 		global $action;
215 221
 
216
-		if (! is_object($outputlangs)) $outputlangs=$langs;
222
+		if (! is_object($outputlangs)) {
223
+		    $outputlangs=$langs;
224
+		}
217 225
 		$sav_charset_output=$outputlangs->charset_output;
218 226
 		$outputlangs->charset_output='UTF-8';
219 227
 
@@ -237,7 +245,9 @@  discard block
 block discarded – undo
237 245
 
238 246
 			$dir = $conf->contrat->dir_output;
239 247
 			$objectref = dol_sanitizeFileName($object->ref);
240
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
248
+			if (! preg_match('/specimen/i',$objectref)) {
249
+			    $dir.= "/" . $objectref;
250
+			}
241 251
 			$file = $dir . "/" . $objectref . ".odt";
242 252
 
243 253
 			if (! file_exists($dir))
@@ -264,10 +274,11 @@  discard block
 block discarded – undo
264 274
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
265 275
 				{
266 276
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
267
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
+				    if ($format == '1') {
278
+				        $format='%Y%m%d%H%M%S';
279
+				    }
268 280
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
269
-				}
270
-				else
281
+				} else
271 282
 				{
272 283
 					$filename=$newfiletmp.'.'.$newfileformat;
273 284
 				}
@@ -294,14 +305,14 @@  discard block
 block discarded – undo
294 305
 				if (! empty($usecontact))
295 306
 				{
296 307
 					// On peut utiliser le nom de la societe du contact
297
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
298
-					else {
308
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
309
+					    $socobject = $object->contact;
310
+					} else {
299 311
                         			$socobject = $object->thirdparty;
300 312
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
301 313
                         			$contactobject = $object->contact;
302 314
                     			}
303
-				}
304
-				else
315
+				} else
305 316
 				{
306 317
 					$socobject=$object->thirdparty;
307 318
 				}
@@ -319,7 +330,9 @@  discard block
 block discarded – undo
319 330
 				$array_other=$this->get_substitutionarray_other($outputlangs);
320 331
 				// retrieve contact information for use in order as contact_xxx tags
321 332
 				$array_thirdparty_contact = array();
322
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
333
+				if ($usecontact && is_object($contactobject)) {
334
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
335
+				}
323 336
 
324 337
 				$substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
325 338
 				complete_substitutions_array($substitutionarray, $outputlangs, $object);
@@ -351,8 +364,7 @@  discard block
 block discarded – undo
351 364
 						'DELIMITER_RIGHT' => '}'
352 365
 						)
353 366
 					);
354
-				}
355
-				catch(Exception $e)
367
+				} catch(Exception $e)
356 368
 				{
357 369
 					$this->error=$e->getMessage();
358 370
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -368,8 +380,7 @@  discard block
 block discarded – undo
368 380
 				// Make substitutions into odt of freetext
369 381
 				try {
370 382
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
371
-				}
372
-				catch (OdfException $e)
383
+				} catch (OdfException $e)
373 384
 				{
374 385
 					dol_syslog($e->getMessage(), LOG_INFO);
375 386
 				}
@@ -377,17 +388,18 @@  discard block
 block discarded – undo
377 388
 				foreach($tmparray as $key=>$value)
378 389
 				{
379 390
 					try {
380
-						if (preg_match('/logo$/',$key)) // Image
391
+						if (preg_match('/logo$/',$key)) {
392
+						    // Image
381 393
 						{
382 394
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
383
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
384
-						}
385
-						else    // Text
395
+						} else {
396
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
397
+							}
398
+						} else    // Text
386 399
 						{
387 400
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
388 401
 						}
389
-					}
390
-					catch (OdfException $e)
402
+					} catch (OdfException $e)
391 403
 					{
392 404
                         dol_syslog($e->getMessage(), LOG_INFO);
393 405
 					}
@@ -399,8 +411,7 @@  discard block
 block discarded – undo
399 411
 					$foundtagforlines = 1;
400 412
 					try {
401 413
 						$listlines = $odfHandler->setSegment('lines');
402
-					}
403
-					catch(OdfException $e)
414
+					} catch(OdfException $e)
404 415
 					{
405 416
 						// We may arrive here if tags for lines not present into template
406 417
 						$foundtagforlines = 0;
@@ -420,12 +431,10 @@  discard block
 block discarded – undo
420 431
 								try
421 432
 								{
422 433
 									$listlines->setVars($key, $val, true, 'UTF-8');
423
-								}
424
-								catch(OdfException $e)
434
+								} catch(OdfException $e)
425 435
 								{
426 436
 									dol_syslog($e->getMessage(), LOG_INFO);
427
-								}
428
-								catch(SegmentException $e)
437
+								} catch(SegmentException $e)
429 438
 								{
430 439
 									dol_syslog($e->getMessage(), LOG_INFO);
431 440
 								}
@@ -434,8 +443,7 @@  discard block
 block discarded – undo
434 443
 						}
435 444
 						$odfHandler->mergeSegment($listlines);
436 445
 					}
437
-				}
438
-				catch(OdfException $e)
446
+				} catch(OdfException $e)
439 447
 				{
440 448
 					$this->error=$e->getMessage();
441 449
 					dol_syslog($this->error, LOG_WARNING);
@@ -448,8 +456,7 @@  discard block
 block discarded – undo
448 456
 				{
449 457
 					try {
450 458
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
451
-					}
452
-					catch(OdfException $e)
459
+					} catch(OdfException $e)
453 460
 					{
454 461
                         dol_syslog($e->getMessage(), LOG_INFO);
455 462
 					}
@@ -467,8 +474,7 @@  discard block
 block discarded – undo
467 474
 						$this->error=$e->getMessage();
468 475
 						return -1;
469 476
 					}
470
-				}
471
-				else {
477
+				} else {
472 478
 					try {
473 479
 					$odfHandler->saveToDisk($file);
474 480
 					} catch (Exception $e) {
@@ -479,16 +485,16 @@  discard block
 block discarded – undo
479 485
 
480 486
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
481 487
 
482
-				if (! empty($conf->global->MAIN_UMASK))
483
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
488
+				if (! empty($conf->global->MAIN_UMASK)) {
489
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
490
+				}
484 491
 
485 492
 				$odfHandler=null;	// Destroy object
486 493
 
487 494
 				$this->result = array('fullpath'=>$file);
488 495
 
489 496
 				return 1;   // Success
490
-			}
491
-			else
497
+			} else
492 498
 			{
493 499
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
494 500
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/modules_contract.php 3 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *  \brief      File with parent class for generating contracts to PDF and File of class to manage contract numbering
30 30
  */
31 31
 
32
- require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
32
+    require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
33 33
 
34 34
 
35 35
 /**
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
  */
38 38
 abstract class ModelePDFContract extends CommonDocGenerator
39 39
 {
40
-	/**
41
-	 * @var string Error code (or message)
42
-	 */
43
-	public $error='';
40
+    /**
41
+     * @var string Error code (or message)
42
+     */
43
+    public $error='';
44 44
 
45 45
 
46 46
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
47
-	/**
48
-	 *	Return list of active generation modules
49
-	 *
47
+    /**
48
+     *	Return list of active generation modules
49
+     *
50 50
      *  @param	DoliDB	$db     			Database handler
51 51
      *  @param  integer	$maxfilenamelength  Max length of value to show
52 52
      *  @return	array						List of templates
53
-	 */
54
-	static function liste_modeles($db,$maxfilenamelength=0)
55
-	{
53
+     */
54
+    static function liste_modeles($db,$maxfilenamelength=0)
55
+    {
56 56
         // phpcs:enable
57
-		global $conf;
57
+        global $conf;
58 58
 
59
-		$type='contract';
60
-		$liste=array();
59
+        $type='contract';
60
+        $liste=array();
61 61
 
62
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
62
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
64 64
 
65
-		return $liste;
66
-	}
65
+        return $liste;
66
+    }
67 67
 }
68 68
 
69 69
 
@@ -72,82 +72,82 @@  discard block
 block discarded – undo
72 72
  */
73 73
 class ModelNumRefContracts
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
-	 *	Return default description of numbering model
92
-	 *
93
-	 *	@return     string      text description
94
-	 */
95
-	function info()
96
-	{
97
-		global $langs;
98
-		$langs->load("contracts");
99
-		return $langs->trans("NoDescription");
100
-	}
101
-
102
-	/**
103
-	 *	Return numbering example
104
-	 *
105
-	 *	@return     string      Example
106
-	 */
107
-	function getExample()
108
-	{
109
-		global $langs;
110
-		$langs->load("contracts");
111
-		return $langs->trans("NoExample");
112
-	}
113
-
114
-	/**
115
-	 *	Test if existing numbers make problems with numbering
116
-	 *
117
-	 *	@return		boolean		false if conflict, true if ok
118
-	 */
119
-	function canBeActivated()
120
-	{
121
-		return true;
122
-	}
123
-
124
-	/**
125
-	 *	Return next value
126
-	 *
127
-	 *	@param	Societe		$objsoc     third party object
128
-	 *	@param	Object		$contract	contract object
129
-	 *	@return	string					Value
130
-	 */
131
-	function getNextValue($objsoc, $contract)
132
-	{
133
-		global $langs;
134
-		return $langs->trans("NotAvailable");
135
-	}
136
-
137
-	/**
138
-	 *	Return numbering version module
139
-	 *
140
-	 *	@return     string      Value
141
-	 */
142
-	function getVersion()
143
-	{
144
-		global $langs;
145
-		$langs->load("admin");
146
-
147
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
-		if ($this->version == 'dolibarr') return DOL_VERSION;
150
-		if ($this->version) return $this->version;
151
-		return $langs->trans("NotAvailable");
152
-	}
75
+    /**
76
+     * @var string Error code (or message)
77
+     */
78
+    public $error='';
79
+
80
+    /**
81
+     *	Return if a module can be used or not
82
+     *
83
+     * 	@return		boolean     true if module can be used
84
+     */
85
+    function isEnabled()
86
+    {
87
+        return true;
88
+    }
89
+
90
+    /**
91
+     *	Return default description of numbering model
92
+     *
93
+     *	@return     string      text description
94
+     */
95
+    function info()
96
+    {
97
+        global $langs;
98
+        $langs->load("contracts");
99
+        return $langs->trans("NoDescription");
100
+    }
101
+
102
+    /**
103
+     *	Return numbering example
104
+     *
105
+     *	@return     string      Example
106
+     */
107
+    function getExample()
108
+    {
109
+        global $langs;
110
+        $langs->load("contracts");
111
+        return $langs->trans("NoExample");
112
+    }
113
+
114
+    /**
115
+     *	Test if existing numbers make problems with numbering
116
+     *
117
+     *	@return		boolean		false if conflict, true if ok
118
+     */
119
+    function canBeActivated()
120
+    {
121
+        return true;
122
+    }
123
+
124
+    /**
125
+     *	Return next value
126
+     *
127
+     *	@param	Societe		$objsoc     third party object
128
+     *	@param	Object		$contract	contract object
129
+     *	@return	string					Value
130
+     */
131
+    function getNextValue($objsoc, $contract)
132
+    {
133
+        global $langs;
134
+        return $langs->trans("NotAvailable");
135
+    }
136
+
137
+    /**
138
+     *	Return numbering version module
139
+     *
140
+     *	@return     string      Value
141
+     */
142
+    function getVersion()
143
+    {
144
+        global $langs;
145
+        $langs->load("admin");
146
+
147
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
+        if ($this->version == 'dolibarr') return DOL_VERSION;
150
+        if ($this->version) return $this->version;
151
+        return $langs->trans("NotAvailable");
152
+    }
153 153
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * @var string Error code (or message)
42 42
 	 */
43
-	public $error='';
43
+	public $error = '';
44 44
 
45 45
 
46 46
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
      *  @param  integer	$maxfilenamelength  Max length of value to show
52 52
      *  @return	array						List of templates
53 53
 	 */
54
-	static function liste_modeles($db,$maxfilenamelength=0)
54
+	static function liste_modeles($db, $maxfilenamelength = 0)
55 55
 	{
56 56
         // phpcs:enable
57 57
 		global $conf;
58 58
 
59
-		$type='contract';
60
-		$liste=array();
59
+		$type = 'contract';
60
+		$liste = array();
61 61
 
62 62
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
63
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
64 64
 
65 65
 		return $liste;
66 66
 	}
@@ -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/contract/mod_contract_magre.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -29,122 +29,122 @@
 block discarded – undo
29 29
  */
30 30
 class mod_contract_magre extends ModelNumRefContracts
31 31
 {
32
-	/**
32
+    /**
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';
37
-
38
-	/**
39
-	 * @var string Error message
40
-	 */
41
-	public $error = '';
42
-
43
-	/**
44
-	 * @var string nom
45
-	 * @deprecated
46
-	 * @see name
47
-	 */
48
-	public $nom='Magre';
49
-
50
-	/**
51
-	 * @var string name
52
-	 */
53
-	public $name='Magre';
54
-
55
-	public $code_auto=1;
56
-
57
-	/**
58
-	 *	Return default description of numbering model
59
-	 *
60
-	 *	@return     string      text description
61
-	 */
62
-	function info()
36
+    public $version = 'dolibarr';
37
+
38
+    /**
39
+     * @var string Error message
40
+     */
41
+    public $error = '';
42
+
43
+    /**
44
+     * @var string nom
45
+     * @deprecated
46
+     * @see name
47
+     */
48
+    public $nom='Magre';
49
+
50
+    /**
51
+     * @var string name
52
+     */
53
+    public $name='Magre';
54
+
55
+    public $code_auto=1;
56
+
57
+    /**
58
+     *	Return default description of numbering model
59
+     *
60
+     *	@return     string      text description
61
+     */
62
+    function info()
63 63
     {
64
-    	global $conf,$langs;
64
+        global $conf,$langs;
65 65
 
66
-		$langs->load("bills");
66
+        $langs->load("bills");
67 67
 
68
-		$form = new Form($this->db);
68
+        $form = new Form($this->db);
69 69
 
70
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
73
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
74
-		$texte.= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
75
-		$texte.= '<table class="nobordernopadding" width="100%">';
70
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
73
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
74
+        $texte.= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
75
+        $texte.= '<table class="nobordernopadding" width="100%">';
76 76
 
77
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
78
-		$tooltip.=$langs->trans("GenericMaskCodes2");
79
-		$tooltip.=$langs->trans("GenericMaskCodes3");
80
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes5");
77
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
78
+        $tooltip.=$langs->trans("GenericMaskCodes2");
79
+        $tooltip.=$langs->trans("GenericMaskCodes3");
80
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
81
+        $tooltip.=$langs->trans("GenericMaskCodes5");
82 82
 
83
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
84
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>';
85
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
86
-		$texte.= '</tr>';
87
-		$texte.= '</table>';
88
-		$texte.= '</form>';
83
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
84
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>';
85
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
86
+        $texte.= '</tr>';
87
+        $texte.= '</table>';
88
+        $texte.= '</form>';
89 89
 
90
-		return $texte;
90
+        return $texte;
91 91
     }
92 92
 
93
-	/**
94
-	 *	Return numbering example
95
-	 *
96
-	 *	@return     string      Example
97
-	 */
93
+    /**
94
+     *	Return numbering example
95
+     *
96
+     *	@return     string      Example
97
+     */
98 98
     function getExample()
99 99
     {
100
-     	global $conf,$langs,$mysoc;
101
-
102
-    	$old_code_client=$mysoc->code_client;
103
-    	$mysoc->code_client='CCCCCCCCCC';
104
-     	$numExample = $this->getNextValue($mysoc,'');
105
-		$mysoc->code_client=$old_code_client;
106
-
107
-		if (! $numExample)
108
-		{
109
-			$numExample = $langs->trans('NotConfigured');
110
-		}
111
-		return $numExample;
100
+            global $conf,$langs,$mysoc;
101
+
102
+        $old_code_client=$mysoc->code_client;
103
+        $mysoc->code_client='CCCCCCCCCC';
104
+            $numExample = $this->getNextValue($mysoc,'');
105
+        $mysoc->code_client=$old_code_client;
106
+
107
+        if (! $numExample)
108
+        {
109
+            $numExample = $langs->trans('NotConfigured');
110
+        }
111
+        return $numExample;
112 112
     }
113 113
 
114
-	/**
115
-	 *	Return next value
116
-	 *
117
-	 *	@param	Societe		$objsoc     third party object
118
-	 *	@param	Object		$contract	contract object
119
-	 *	@return string      			Value if OK, 0 if KO
120
-	 */
114
+    /**
115
+     *	Return next value
116
+     *
117
+     *	@param	Societe		$objsoc     third party object
118
+     *	@param	Object		$contract	contract object
119
+     *	@return string      			Value if OK, 0 if KO
120
+     */
121 121
     function getNextValue($objsoc,$contract)
122 122
     {
123
-		global $db,$conf;
123
+        global $db,$conf;
124 124
 
125
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
125
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
126 126
 
127
-		$mask=$conf->global->CONTRACT_MAGRE_MASK;
127
+        $mask=$conf->global->CONTRACT_MAGRE_MASK;
128 128
 
129
-		if (! $mask)
130
-		{
131
-			$this->error='NotConfigured';
132
-			return 0;
133
-		}
129
+        if (! $mask)
130
+        {
131
+            $this->error='NotConfigured';
132
+            return 0;
133
+        }
134 134
 
135
-		$numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
135
+        $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
136 136
 
137
-		return  $numFinal;
138
-	}
137
+        return  $numFinal;
138
+    }
139 139
 
140 140
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
141
-	/**
142
-	 *  Return next value
143
-	 *
144
-	 *	@param	Societe		$objsoc     third party object
145
-	 *	@param	Object		$objforref	contract object
146
-	 *	@return string      			Value if OK, 0 if KO
147
-	 */
141
+    /**
142
+     *  Return next value
143
+     *
144
+     *	@param	Societe		$objsoc     third party object
145
+     *	@param	Object		$objforref	contract object
146
+     *	@return string      			Value if OK, 0 if KO
147
+     */
148 148
     function contract_get_num($objsoc,$objforref)
149 149
     {
150 150
         // phpcs:enable
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *  \brief      File of class to manage contract numbering rules Magre
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/contract/modules_contract.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
26 26
 
27 27
 /**
28 28
  *	Class to manage contract numbering rules Magre
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 * @deprecated
46 46
 	 * @see name
47 47
 	 */
48
-	public $nom='Magre';
48
+	public $nom = 'Magre';
49 49
 
50 50
 	/**
51 51
 	 * @var string name
52 52
 	 */
53
-	public $name='Magre';
53
+	public $name = 'Magre';
54 54
 
55
-	public $code_auto=1;
55
+	public $code_auto = 1;
56 56
 
57 57
 	/**
58 58
 	 *	Return default description of numbering model
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	function info()
63 63
     {
64
-    	global $conf,$langs;
64
+    	global $conf, $langs;
65 65
 
66 66
 		$langs->load("bills");
67 67
 
68 68
 		$form = new Form($this->db);
69 69
 
70 70
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
73
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
74
-		$texte.= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
75
-		$texte.= '<table class="nobordernopadding" width="100%">';
76
-
77
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
78
-		$tooltip.=$langs->trans("GenericMaskCodes2");
79
-		$tooltip.=$langs->trans("GenericMaskCodes3");
80
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes5");
82
-
83
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
84
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>';
85
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
86
-		$texte.= '</tr>';
87
-		$texte.= '</table>';
88
-		$texte.= '</form>';
71
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
73
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
74
+		$texte .= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
75
+		$texte .= '<table class="nobordernopadding" width="100%">';
76
+
77
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
78
+		$tooltip .= $langs->trans("GenericMaskCodes2");
79
+		$tooltip .= $langs->trans("GenericMaskCodes3");
80
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
81
+		$tooltip .= $langs->trans("GenericMaskCodes5");
82
+
83
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
84
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">', $tooltip, 1, 1).'</td>';
85
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
86
+		$texte .= '</tr>';
87
+		$texte .= '</table>';
88
+		$texte .= '</form>';
89 89
 
90 90
 		return $texte;
91 91
     }
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
     function getExample()
99 99
     {
100
-     	global $conf,$langs,$mysoc;
100
+     	global $conf, $langs, $mysoc;
101 101
 
102
-    	$old_code_client=$mysoc->code_client;
103
-    	$mysoc->code_client='CCCCCCCCCC';
104
-     	$numExample = $this->getNextValue($mysoc,'');
105
-		$mysoc->code_client=$old_code_client;
102
+    	$old_code_client = $mysoc->code_client;
103
+    	$mysoc->code_client = 'CCCCCCCCCC';
104
+     	$numExample = $this->getNextValue($mysoc, '');
105
+		$mysoc->code_client = $old_code_client;
106 106
 
107
-		if (! $numExample)
107
+		if (!$numExample)
108 108
 		{
109 109
 			$numExample = $langs->trans('NotConfigured');
110 110
 		}
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
 	 *	@param	Object		$contract	contract object
119 119
 	 *	@return string      			Value if OK, 0 if KO
120 120
 	 */
121
-    function getNextValue($objsoc,$contract)
121
+    function getNextValue($objsoc, $contract)
122 122
     {
123
-		global $db,$conf;
123
+		global $db, $conf;
124 124
 
125
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
125
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
126 126
 
127
-		$mask=$conf->global->CONTRACT_MAGRE_MASK;
127
+		$mask = $conf->global->CONTRACT_MAGRE_MASK;
128 128
 
129
-		if (! $mask)
129
+		if (!$mask)
130 130
 		{
131
-			$this->error='NotConfigured';
131
+			$this->error = 'NotConfigured';
132 132
 			return 0;
133 133
 		}
134 134
 
135
-		$numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
135
+		$numFinal = get_next_value($db, $mask, 'contrat', 'ref', '', $objsoc, $contract->date_contrat);
136 136
 
137 137
 		return  $numFinal;
138 138
 	}
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 *	@param	Object		$objforref	contract object
146 146
 	 *	@return string      			Value if OK, 0 if KO
147 147
 	 */
148
-    function contract_get_num($objsoc,$objforref)
148
+    function contract_get_num($objsoc, $objforref)
149 149
     {
150 150
         // phpcs:enable
151
-        return $this->getNextValue($objsoc,$objforref);
151
+        return $this->getNextValue($objsoc, $objforref);
152 152
     }
153 153
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/contract/mod_contract_olive.php 3 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -33,92 +33,92 @@
 block discarded – undo
33 33
 class mod_contract_olive extends ModelNumRefContracts
34 34
 {
35 35
     /**
36
-	 * @var string Nom du modele
37
-	 * @deprecated
38
-	 * @see name
39
-	 */
40
-	public $nom='Olive';
36
+     * @var string Nom du modele
37
+     * @deprecated
38
+     * @see name
39
+     */
40
+    public $nom='Olive';
41 41
 
42
-	/**
43
-	 * @var string model name
44
-	 */
45
-	public $name='Olive';
42
+    /**
43
+     * @var string model name
44
+     */
45
+    public $name='Olive';
46 46
 
47
-	public $code_modifiable = 1;				// Code modifiable
47
+    public $code_modifiable = 1;				// Code modifiable
48 48
 
49
-	public $code_modifiable_invalide = 1;		// Code modifiable si il est invalide
49
+    public $code_modifiable_invalide = 1;		// Code modifiable si il est invalide
50 50
 
51
-	public $code_modifiable_null = 1;			// Code modifiables si il est null
51
+    public $code_modifiable_null = 1;			// Code modifiables si il est null
52 52
 
53
-	public $code_null = 1;						// Code facultatif
53
+    public $code_null = 1;						// Code facultatif
54 54
 
55
-	/**
55
+    /**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
60
-
61
-	public $code_auto = 0; 	                // Numerotation automatique
62
-
63
-
64
-	/**
65
-	 *	Return description of module
66
-	 *
67
-	 *	@return string      		Description of module
68
-	 */
69
-	function info()
70
-	{
71
-		global $langs;
72
-
73
-		$langs->load("companies");
74
-		return $langs->trans("LeopardNumRefModelDesc");
75
-	}
76
-
77
-	/**
78
-	 * Return an example of result returned by getNextValue
79
-	 *
80
-	 * @param	Societe		$objsoc		Object thirdparty
81
-	 * @param	Contrat		$contract	Object contract
82
-	 * @return	string					Return next value
83
-	 */
84
-	function getNextValue($objsoc,$contract)
85
-	{
86
-		global $langs;
87
-		return '';
88
-	}
89
-
90
-
91
-	/**
92
-	 * 	Check validity of code according to its rules
93
-	 *
94
-	 *	@param	DoliDB		$db		Database handler
95
-	 *	@param	string		$code	Code to check/correct
96
-	 *	@param	Product		$product	Object product
97
-	 *  @param  int		  	$type   0 = product , 1 = service
98
-	 *  @return int					0 if OK
99
-	 * 								-1 ErrorBadProductCodeSyntax
100
-	 * 								-2 ErrorProductCodeRequired
101
-	 * 								-3 ErrorProductCodeAlreadyUsed
102
-	 * 								-4 ErrorPrefixRequired
103
-	 */
104
-	function verif($db, &$code, $product, $type)
105
-	{
106
-		global $conf;
107
-
108
-		$result=0;
109
-		$code = strtoupper(trim($code));
110
-
111
-		if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))
112
-		{
113
-			$result=0;
114
-		}
115
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) )
116
-		{
117
-			$result=-2;
118
-		}
119
-
120
-		dol_syslog("mod_contract_olive::verif type=".$type." result=".$result);
121
-		return $result;
122
-	}
59
+    public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
60
+
61
+    public $code_auto = 0; 	                // Numerotation automatique
62
+
63
+
64
+    /**
65
+     *	Return description of module
66
+     *
67
+     *	@return string      		Description of module
68
+     */
69
+    function info()
70
+    {
71
+        global $langs;
72
+
73
+        $langs->load("companies");
74
+        return $langs->trans("LeopardNumRefModelDesc");
75
+    }
76
+
77
+    /**
78
+     * Return an example of result returned by getNextValue
79
+     *
80
+     * @param	Societe		$objsoc		Object thirdparty
81
+     * @param	Contrat		$contract	Object contract
82
+     * @return	string					Return next value
83
+     */
84
+    function getNextValue($objsoc,$contract)
85
+    {
86
+        global $langs;
87
+        return '';
88
+    }
89
+
90
+
91
+    /**
92
+     * 	Check validity of code according to its rules
93
+     *
94
+     *	@param	DoliDB		$db		Database handler
95
+     *	@param	string		$code	Code to check/correct
96
+     *	@param	Product		$product	Object product
97
+     *  @param  int		  	$type   0 = product , 1 = service
98
+     *  @return int					0 if OK
99
+     * 								-1 ErrorBadProductCodeSyntax
100
+     * 								-2 ErrorProductCodeRequired
101
+     * 								-3 ErrorProductCodeAlreadyUsed
102
+     * 								-4 ErrorPrefixRequired
103
+     */
104
+    function verif($db, &$code, $product, $type)
105
+    {
106
+        global $conf;
107
+
108
+        $result=0;
109
+        $code = strtoupper(trim($code));
110
+
111
+        if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))
112
+        {
113
+            $result=0;
114
+        }
115
+        else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) )
116
+        {
117
+            $result=-2;
118
+        }
119
+
120
+        dol_syslog("mod_contract_olive::verif type=".$type." result=".$result);
121
+        return $result;
122
+    }
123 123
 }
124 124
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *  \brief      File of class to manage contract numbering rules Olive
25 25
  */
26 26
 
27
-require_once DOL_DOCUMENT_ROOT .'/core/modules/contract/modules_contract.php';
27
+require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
28 28
 
29 29
 
30 30
 /**
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
 	 * @deprecated
38 38
 	 * @see name
39 39
 	 */
40
-	public $nom='Olive';
40
+	public $nom = 'Olive';
41 41
 
42 42
 	/**
43 43
 	 * @var string model name
44 44
 	 */
45
-	public $name='Olive';
45
+	public $name = 'Olive';
46 46
 
47
-	public $code_modifiable = 1;				// Code modifiable
47
+	public $code_modifiable = 1; // Code modifiable
48 48
 
49
-	public $code_modifiable_invalide = 1;		// Code modifiable si il est invalide
49
+	public $code_modifiable_invalide = 1; // Code modifiable si il est invalide
50 50
 
51
-	public $code_modifiable_null = 1;			// Code modifiables si il est null
51
+	public $code_modifiable_null = 1; // Code modifiables si il est null
52 52
 
53
-	public $code_null = 1;						// Code facultatif
53
+	public $code_null = 1; // Code facultatif
54 54
 
55 55
 	/**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
59
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
60 60
 
61
-	public $code_auto = 0; 	                // Numerotation automatique
61
+	public $code_auto = 0; // Numerotation automatique
62 62
 
63 63
 
64 64
 	/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @param	Contrat		$contract	Object contract
82 82
 	 * @return	string					Return next value
83 83
 	 */
84
-	function getNextValue($objsoc,$contract)
84
+	function getNextValue($objsoc, $contract)
85 85
 	{
86 86
 		global $langs;
87 87
 		return '';
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 	{
106 106
 		global $conf;
107 107
 
108
-		$result=0;
108
+		$result = 0;
109 109
 		$code = strtoupper(trim($code));
110 110
 
111 111
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))
112 112
 		{
113
-			$result=0;
113
+			$result = 0;
114 114
 		}
115
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) )
115
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)))
116 116
 		{
117
-			$result=-2;
117
+			$result = -2;
118 118
 		}
119 119
 
120 120
 		dol_syslog("mod_contract_olive::verif type=".$type." result=".$result);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@
 block discarded – undo
111 111
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))
112 112
 		{
113 113
 			$result=0;
114
-		}
115
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) )
114
+		} else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) )
116 115
 		{
117 116
 			$result=-2;
118 117
 		}
Please login to merge, or discard this patch.