Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/facture/mod_facture_terre.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -29,176 +29,176 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class mod_facture_terre extends ModeleNumRefFactures
31 31
 {
32
-	/**
32
+    /**
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
-
38
-	public $prefixinvoice='FA';
39
-
40
-	public $prefixcreditnote='AV';
41
-
42
-	public $prefixdeposit='AC';
43
-
44
-	/**
45
-	 * @var string Error code (or message)
46
-	 */
47
-	public $error='';
48
-
49
-
50
-	/**
51
-	 * Constructor
52
-	 */
53
-	function __construct()
54
-	{
55
-		if (! empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX))
56
-		{
57
-			$this->prefixinvoice = $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX;
58
-		}
59
-	}
60
-
61
-	/**
62
-	 *  Renvoi la description du modele de numerotation
63
-	 *
64
-	 *  @return     string      Texte descripif
65
-	 */
66
-	function info()
67
-	{
68
-		global $langs;
69
-		$langs->load("bills");
70
-		return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit);
71
-	}
72
-
73
-	/**
74
-	 *  Renvoi un exemple de numerotation
75
-	 *
76
-	 *  @return     string      Example
77
-	 */
78
-	function getExample()
79
-	{
80
-		return $this->prefixinvoice."0501-0001";
81
-	}
82
-
83
-	/**
84
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
85
-	 *  de conflits qui empechera cette numerotation de fonctionner.
86
-	 *
87
-	 *  @return     boolean     false si conflit, true si ok
88
-	 */
89
-	function canBeActivated()
90
-	{
91
-		global $langs,$conf,$db;
92
-
93
-		$langs->load("bills");
94
-
95
-		// Check invoice num
96
-		$fayymm=''; $max='';
97
-
98
-		$posindice=8;
99
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
100
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
101
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
102
-		$sql.= " AND entity = ".$conf->entity;
103
-
104
-		$resql=$db->query($sql);
105
-		if ($resql)
106
-		{
107
-			$row = $db->fetch_row($resql);
108
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
109
-		}
110
-		if ($fayymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$fayymm))
111
-		{
112
-			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
114
-			return false;
115
-		}
116
-
117
-		// Check credit note num
118
-		$fayymm='';
119
-
120
-		$posindice=8;
121
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
122
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
123
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
124
-		$sql.= " AND entity = ".$conf->entity;
125
-
126
-		$resql=$db->query($sql);
127
-		if ($resql)
128
-		{
129
-			$row = $db->fetch_row($resql);
130
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
131
-		}
132
-		if ($fayymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$fayymm))
133
-		{
134
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
135
-			return false;
136
-		}
137
-
138
-		// Check deposit num
139
-		$fayymm='';
140
-
141
-		$posindice=8;
142
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
143
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
144
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
145
-		$sql.= " AND entity = ".$conf->entity;
146
-
147
-		$resql=$db->query($sql);
148
-		if ($resql)
149
-		{
150
-			$row = $db->fetch_row($resql);
151
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
152
-		}
153
-		if ($fayymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$fayymm))
154
-		{
155
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
156
-			return false;
157
-		}
158
-
159
-		return true;
160
-	}
161
-
162
-	/**
163
-	 * Return next value not used or last value used
164
-	 *
165
-	 * @param	Societe		$objsoc		Object third party
166
-	 * @param   Facture		$invoice	Object invoice
36
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+
38
+    public $prefixinvoice='FA';
39
+
40
+    public $prefixcreditnote='AV';
41
+
42
+    public $prefixdeposit='AC';
43
+
44
+    /**
45
+     * @var string Error code (or message)
46
+     */
47
+    public $error='';
48
+
49
+
50
+    /**
51
+     * Constructor
52
+     */
53
+    function __construct()
54
+    {
55
+        if (! empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX))
56
+        {
57
+            $this->prefixinvoice = $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX;
58
+        }
59
+    }
60
+
61
+    /**
62
+     *  Renvoi la description du modele de numerotation
63
+     *
64
+     *  @return     string      Texte descripif
65
+     */
66
+    function info()
67
+    {
68
+        global $langs;
69
+        $langs->load("bills");
70
+        return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit);
71
+    }
72
+
73
+    /**
74
+     *  Renvoi un exemple de numerotation
75
+     *
76
+     *  @return     string      Example
77
+     */
78
+    function getExample()
79
+    {
80
+        return $this->prefixinvoice."0501-0001";
81
+    }
82
+
83
+    /**
84
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
85
+     *  de conflits qui empechera cette numerotation de fonctionner.
86
+     *
87
+     *  @return     boolean     false si conflit, true si ok
88
+     */
89
+    function canBeActivated()
90
+    {
91
+        global $langs,$conf,$db;
92
+
93
+        $langs->load("bills");
94
+
95
+        // Check invoice num
96
+        $fayymm=''; $max='';
97
+
98
+        $posindice=8;
99
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
100
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture";
101
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
102
+        $sql.= " AND entity = ".$conf->entity;
103
+
104
+        $resql=$db->query($sql);
105
+        if ($resql)
106
+        {
107
+            $row = $db->fetch_row($resql);
108
+            if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
109
+        }
110
+        if ($fayymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$fayymm))
111
+        {
112
+            $langs->load("errors");
113
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
114
+            return false;
115
+        }
116
+
117
+        // Check credit note num
118
+        $fayymm='';
119
+
120
+        $posindice=8;
121
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
122
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture";
123
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
124
+        $sql.= " AND entity = ".$conf->entity;
125
+
126
+        $resql=$db->query($sql);
127
+        if ($resql)
128
+        {
129
+            $row = $db->fetch_row($resql);
130
+            if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
131
+        }
132
+        if ($fayymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$fayymm))
133
+        {
134
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
135
+            return false;
136
+        }
137
+
138
+        // Check deposit num
139
+        $fayymm='';
140
+
141
+        $posindice=8;
142
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
143
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture";
144
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
145
+        $sql.= " AND entity = ".$conf->entity;
146
+
147
+        $resql=$db->query($sql);
148
+        if ($resql)
149
+        {
150
+            $row = $db->fetch_row($resql);
151
+            if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
152
+        }
153
+        if ($fayymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$fayymm))
154
+        {
155
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
156
+            return false;
157
+        }
158
+
159
+        return true;
160
+    }
161
+
162
+    /**
163
+     * Return next value not used or last value used
164
+     *
165
+     * @param	Societe		$objsoc		Object third party
166
+     * @param   Facture		$invoice	Object invoice
167 167
      * @param   string		$mode       'next' for next value or 'last' for last value
168
-	 * @return  string       			Value
169
-	 */
170
-	function getNextValue($objsoc, $invoice, $mode='next')
171
-	{
172
-		global $db;
173
-
174
-		if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
175
-		else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
176
-		else $prefix=$this->prefixinvoice;
177
-
178
-		// D'abord on recupere la valeur max
179
-		$posindice=8;
180
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
181
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
182
-		$sql.= " WHERE ref LIKE '".$prefix."____-%'";
183
-		$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
184
-
185
-		$resql=$db->query($sql);
186
-		dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
187
-		if ($resql)
188
-		{
189
-			$obj = $db->fetch_object($resql);
190
-			if ($obj) $max = intval($obj->max);
191
-			else $max=0;
192
-		}
193
-		else
194
-		{
195
-			return -1;
196
-		}
197
-
198
-		if ($mode == 'last')
199
-		{
200
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
201
-    		else $num = sprintf("%04s",$max);
168
+     * @return  string       			Value
169
+     */
170
+    function getNextValue($objsoc, $invoice, $mode='next')
171
+    {
172
+        global $db;
173
+
174
+        if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
175
+        else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
176
+        else $prefix=$this->prefixinvoice;
177
+
178
+        // D'abord on recupere la valeur max
179
+        $posindice=8;
180
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
181
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture";
182
+        $sql.= " WHERE ref LIKE '".$prefix."____-%'";
183
+        $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
184
+
185
+        $resql=$db->query($sql);
186
+        dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
187
+        if ($resql)
188
+        {
189
+            $obj = $db->fetch_object($resql);
190
+            if ($obj) $max = intval($obj->max);
191
+            else $max=0;
192
+        }
193
+        else
194
+        {
195
+            return -1;
196
+        }
197
+
198
+        if ($mode == 'last')
199
+        {
200
+            if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
201
+            else $num = sprintf("%04s",$max);
202 202
 
203 203
             $ref='';
204 204
             $sql = "SELECT ref as ref";
@@ -216,32 +216,32 @@  discard block
 block discarded – undo
216 216
             else dol_print_error($db);
217 217
 
218 218
             return $ref;
219
-		}
220
-		else if ($mode == 'next')
221
-		{
222
-			$date=$invoice->date;	// This is invoice date (not creation date)
223
-    		$yymm = strftime("%y%m",$date);
224
-
225
-    		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
226
-    		else $num = sprintf("%04s",$max+1);
227
-
228
-    		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
229
-    		return $prefix.$yymm."-".$num;
230
-		}
231
-		else dol_print_error('','Bad parameter for getNextValue');
232
-	}
233
-
234
-	/**
235
-	 * Return next free value
236
-	 *
219
+        }
220
+        else if ($mode == 'next')
221
+        {
222
+            $date=$invoice->date;	// This is invoice date (not creation date)
223
+            $yymm = strftime("%y%m",$date);
224
+
225
+            if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
226
+            else $num = sprintf("%04s",$max+1);
227
+
228
+            dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
229
+            return $prefix.$yymm."-".$num;
230
+        }
231
+        else dol_print_error('','Bad parameter for getNextValue');
232
+    }
233
+
234
+    /**
235
+     * Return next free value
236
+     *
237 237
      * @param	Societe		$objsoc     	Object third party
238 238
      * @param	string		$objforref		Object for number to search
239 239
      * @param   string		$mode       	'next' for next value or 'last' for last value
240 240
      * @return  string      				Next free value
241
-	 */
242
-	function getNumRef($objsoc,$objforref,$mode='next')
243
-	{
244
-		return $this->getNextValue($objsoc,$objforref,$mode);
245
-	}
241
+     */
242
+    function getNumRef($objsoc,$objforref,$mode='next')
243
+    {
244
+        return $this->getNextValue($objsoc,$objforref,$mode);
245
+    }
246 246
 }
247 247
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modDav.class.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -31,121 +31,121 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class modDav extends DolibarrModules
33 33
 {
34
-	/**
35
-	 * Constructor. Define names, constants, directories, boxes, permissions
36
-	 *
37
-	 * @param DoliDB $db Database handler
38
-	 */
39
-	public function __construct($db)
40
-	{
34
+    /**
35
+     * Constructor. Define names, constants, directories, boxes, permissions
36
+     *
37
+     * @param DoliDB $db Database handler
38
+     */
39
+    public function __construct($db)
40
+    {
41 41
         global $langs,$conf;
42 42
 
43 43
         $this->db = $db;
44 44
 
45
-		// Id for module (must be unique).
46
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
47
-		$this->numero = 50310;
48
-		// Key text used to identify module (for permissions, menus, etc...)
49
-		$this->rights_class = 'dav';
50
-
51
-		// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
52
-		// It is used to group modules by family in module setup page
53
-		$this->family = "interface";
54
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
55
-		$this->module_position = '75';
56
-		// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
57
-		//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
58
-
59
-		// Module label (no space allowed), used if translation string 'ModuledavName' not found (MyModue is name of module).
60
-		$this->name = preg_replace('/^mod/i','',get_class($this));
61
-		// Module description, used if translation string 'ModuledavDesc' not found (MyModue is name of module).
62
-		$this->description = "davDescription";
63
-		// Used only if file README.md and README-LL.md not found.
64
-		$this->descriptionlong = "davDescription";
65
-
66
-		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
67
-		$this->version = 'dolibarr';
68
-		// Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase)
69
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70
-		// Name of image file used for this module.
71
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
72
-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
73
-		$this->picto='generic';
74
-
75
-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
76
-		// for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable)
77
-		// for specific path of parts (eg: /dav/core/modules/barcode)
78
-		// for specific css file (eg: /dav/css/dav.css.php)
79
-		$this->module_parts = array();
80
-
81
-		// Data directories to create when module is enabled.
82
-		// Example: this->dirs = array("/dav/temp","/dav/subdir");
83
-		$this->dirs = array("/dav/temp","/dav/public","/dav/private");
84
-
85
-		// Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module.
86
-		$this->config_page_url = array("dav.php");
87
-
88
-		// Dependencies
89
-		$this->hidden = false;			// A condition to hide module
90
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
91
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
92
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
93
-		$this->langfiles = array("admin");
94
-		$this->phpmin = array(5,6);					// Minimum version of PHP required by module
95
-		$this->need_dolibarr_version = array(7,0);	// Minimum version of Dolibarr required by module
96
-		$this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
97
-		$this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
98
-		//$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
99
-		//$this->always_enabled = true;								// If true, can't be disabled
100
-
101
-		// Constants
102
-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
103
-		// Example: $this->const=array(0=>array('DAV_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
104
-		//                             1=>array('DAV_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
105
-		// );
106
-		$this->const = array(
107
-			//1=>array('DAV_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
108
-		);
109
-
110
-
111
-		if (! isset($conf->dav) || ! isset($conf->dav->enabled))
112
-		{
113
-			$conf->dav=new stdClass();
114
-			$conf->dav->enabled=0;
115
-		}
116
-
117
-
118
-		// Array to add new pages in new tabs
45
+        // Id for module (must be unique).
46
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
47
+        $this->numero = 50310;
48
+        // Key text used to identify module (for permissions, menus, etc...)
49
+        $this->rights_class = 'dav';
50
+
51
+        // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
52
+        // It is used to group modules by family in module setup page
53
+        $this->family = "interface";
54
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
55
+        $this->module_position = '75';
56
+        // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
57
+        //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
58
+
59
+        // Module label (no space allowed), used if translation string 'ModuledavName' not found (MyModue is name of module).
60
+        $this->name = preg_replace('/^mod/i','',get_class($this));
61
+        // Module description, used if translation string 'ModuledavDesc' not found (MyModue is name of module).
62
+        $this->description = "davDescription";
63
+        // Used only if file README.md and README-LL.md not found.
64
+        $this->descriptionlong = "davDescription";
65
+
66
+        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
67
+        $this->version = 'dolibarr';
68
+        // Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase)
69
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70
+        // Name of image file used for this module.
71
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
72
+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
73
+        $this->picto='generic';
74
+
75
+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
76
+        // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable)
77
+        // for specific path of parts (eg: /dav/core/modules/barcode)
78
+        // for specific css file (eg: /dav/css/dav.css.php)
79
+        $this->module_parts = array();
80
+
81
+        // Data directories to create when module is enabled.
82
+        // Example: this->dirs = array("/dav/temp","/dav/subdir");
83
+        $this->dirs = array("/dav/temp","/dav/public","/dav/private");
84
+
85
+        // Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module.
86
+        $this->config_page_url = array("dav.php");
87
+
88
+        // Dependencies
89
+        $this->hidden = false;			// A condition to hide module
90
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
91
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
92
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
93
+        $this->langfiles = array("admin");
94
+        $this->phpmin = array(5,6);					// Minimum version of PHP required by module
95
+        $this->need_dolibarr_version = array(7,0);	// Minimum version of Dolibarr required by module
96
+        $this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
97
+        $this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
98
+        //$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
99
+        //$this->always_enabled = true;								// If true, can't be disabled
100
+
101
+        // Constants
102
+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
103
+        // Example: $this->const=array(0=>array('DAV_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
104
+        //                             1=>array('DAV_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
105
+        // );
106
+        $this->const = array(
107
+            //1=>array('DAV_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
108
+        );
109
+
110
+
111
+        if (! isset($conf->dav) || ! isset($conf->dav->enabled))
112
+        {
113
+            $conf->dav=new stdClass();
114
+            $conf->dav->enabled=0;
115
+        }
116
+
117
+
118
+        // Array to add new pages in new tabs
119 119
         $this->tabs = array();
120
-		// Example:
121
-		// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@dav:$user->rights->dav->read:/dav/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
120
+        // Example:
121
+        // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@dav:$user->rights->dav->read:/dav/mynewtab1.php?id=__ID__');  					// To add a new tab identified by code tabname1
122 122
         // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
123 123
         // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname
124 124
         //
125 125
         // Where objecttype can be
126
-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
127
-		// 'contact'          to add a tab in contact view
128
-		// 'contract'         to add a tab in contract view
129
-		// 'group'            to add a tab in group view
130
-		// 'intervention'     to add a tab in intervention view
131
-		// 'invoice'          to add a tab in customer invoice view
132
-		// 'invoice_supplier' to add a tab in supplier invoice view
133
-		// 'member'           to add a tab in fundation member view
134
-		// 'opensurveypoll'	  to add a tab in opensurvey poll view
135
-		// 'order'            to add a tab in customer order view
136
-		// 'order_supplier'   to add a tab in supplier order view
137
-		// 'payment'		  to add a tab in payment view
138
-		// 'payment_supplier' to add a tab in supplier payment view
139
-		// 'product'          to add a tab in product view
140
-		// 'propal'           to add a tab in propal view
141
-		// 'project'          to add a tab in project view
142
-		// 'stock'            to add a tab in stock view
143
-		// 'thirdparty'       to add a tab in third party view
144
-		// 'user'             to add a tab in user view
126
+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
127
+        // 'contact'          to add a tab in contact view
128
+        // 'contract'         to add a tab in contract view
129
+        // 'group'            to add a tab in group view
130
+        // 'intervention'     to add a tab in intervention view
131
+        // 'invoice'          to add a tab in customer invoice view
132
+        // 'invoice_supplier' to add a tab in supplier invoice view
133
+        // 'member'           to add a tab in fundation member view
134
+        // 'opensurveypoll'	  to add a tab in opensurvey poll view
135
+        // 'order'            to add a tab in customer order view
136
+        // 'order_supplier'   to add a tab in supplier order view
137
+        // 'payment'		  to add a tab in payment view
138
+        // 'payment_supplier' to add a tab in supplier payment view
139
+        // 'product'          to add a tab in product view
140
+        // 'propal'           to add a tab in propal view
141
+        // 'project'          to add a tab in project view
142
+        // 'stock'            to add a tab in stock view
143
+        // 'thirdparty'       to add a tab in third party view
144
+        // 'user'             to add a tab in user view
145 145
 
146 146
 
147 147
         // Dictionaries
148
-		$this->dictionaries=array();
148
+        $this->dictionaries=array();
149 149
         /* Example:
150 150
         $this->dictionaries=array(
151 151
             'langs'=>'mylangfile@dav',
@@ -163,28 +163,28 @@  discard block
 block discarded – undo
163 163
 
164 164
 
165 165
         // Boxes/Widgets
166
-		// Add here list of php file(s) stored in dav/core/boxes that contains class to show a widget.
166
+        // Add here list of php file(s) stored in dav/core/boxes that contains class to show a widget.
167 167
         $this->boxes = array(
168
-        	//0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'),
169
-        	//1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'),
170
-        	//2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav')
168
+            //0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'),
169
+            //1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'),
170
+            //2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav')
171 171
         );
172 172
 
173 173
 
174
-		// Cronjobs (List of cron jobs entries to add when module is enabled)
175
-		// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
176
-		//$this->cronjobs = array(
177
-			//0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/dav/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
178
-		//);
179
-		// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
180
-		//                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
181
-		// );
174
+        // Cronjobs (List of cron jobs entries to add when module is enabled)
175
+        // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
176
+        //$this->cronjobs = array(
177
+            //0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/dav/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
178
+        //);
179
+        // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
180
+        //                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
181
+        // );
182 182
 
183 183
 
184
-		// Permissions
185
-		$this->rights = array();		// Permission array used by this module
184
+        // Permissions
185
+        $this->rights = array();		// Permission array used by this module
186 186
 
187
-		/*
187
+        /*
188 188
 		$r=0;
189 189
 		$this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
190 190
 		$this->rights[$r][1] = 'Read myobject of dav';	// Permission label
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 		$this->rights[$r][5] = '';				    // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
208 208
 		*/
209 209
 
210
-		// Main menu entries
211
-		$this->menu = array();			// List of menus to add
212
-		$r=0;
210
+        // Main menu entries
211
+        $this->menu = array();			// List of menus to add
212
+        $r=0;
213 213
 
214
-		// Add here entries to declare new menus
214
+        // Add here entries to declare new menus
215 215
 
216
-		/* BEGIN MODULEBUILDER TOPMENU */
217
-		/*$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
216
+        /* BEGIN MODULEBUILDER TOPMENU */
217
+        /*$this->menu[$r++]=array('fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
218 218
 								'type'=>'top',			                // This is a Top menu entry
219 219
 								'titre'=>'dav',
220 220
 								'mainmenu'=>'dav',
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 								'target'=>'',
228 228
 								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
229 229
 		*/
230
-		/* END MODULEBUILDER TOPMENU */
230
+        /* END MODULEBUILDER TOPMENU */
231 231
 
232
-		/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
232
+        /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
233 233
 		$this->menu[$r++]=array(	'fk_menu'=>'fk_mainmenu=dav',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
234 234
 								'type'=>'left',			                // This is a Left menu entry
235 235
 								'titre'=>'List MyObject',
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 		END MODULEBUILDER LEFTMENU MYOBJECT */
258 258
 
259 259
 
260
-		// Exports
261
-		$r=1;
260
+        // Exports
261
+        $r=1;
262 262
 
263
-		/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
264
-		/*
263
+        /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
264
+        /*
265 265
 		$langs->load("dav@dav");
266 266
 		$this->export_code[$r]=$this->rights_class.'_'.$r;
267 267
 		$this->export_label[$r]='MyObjectLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
@@ -276,48 +276,48 @@  discard block
 block discarded – undo
276 276
 		$this->export_sql_end[$r] .=' WHERE 1 = 1';
277 277
 		$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
278 278
 		$r++; */
279
-		/* END MODULEBUILDER EXPORT MYOBJECT */
280
-	}
281
-
282
-	/**
283
-	 *	Function called when module is enabled.
284
-	 *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
285
-	 *	It also creates data directories
286
-	 *
279
+        /* END MODULEBUILDER EXPORT MYOBJECT */
280
+    }
281
+
282
+    /**
283
+     *	Function called when module is enabled.
284
+     *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
285
+     *	It also creates data directories
286
+     *
287
+     *	@param      string	$options    Options when enabling module ('', 'noboxes')
288
+     *	@return     int             	1 if OK, 0 if KO
289
+     */
290
+    public function init($options='')
291
+    {
292
+        //$this->_load_tables('/dav/sql/');
293
+
294
+        // Create extrafields
295
+        include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
296
+        $extrafields = new ExtraFields($this->db);
297
+
298
+        //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
299
+        //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
300
+        //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
301
+        //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1 '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
302
+        //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
303
+
304
+        $sql = array();
305
+
306
+        return $this->_init($sql, $options);
307
+    }
308
+
309
+    /**
310
+     *	Function called when module is disabled.
311
+     *	Remove from database constants, boxes and permissions from Dolibarr database.
312
+     *	Data directories are not deleted
313
+     *
287 314
      *	@param      string	$options    Options when enabling module ('', 'noboxes')
288
-	 *	@return     int             	1 if OK, 0 if KO
289
-	 */
290
-	public function init($options='')
291
-	{
292
-		//$this->_load_tables('/dav/sql/');
293
-
294
-		// Create extrafields
295
-		include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
296
-		$extrafields = new ExtraFields($this->db);
297
-
298
-		//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
299
-		//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
300
-		//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
301
-		//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1 '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
302
-		//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
303
-
304
-		$sql = array();
305
-
306
-		return $this->_init($sql, $options);
307
-	}
308
-
309
-	/**
310
-	 *	Function called when module is disabled.
311
-	 *	Remove from database constants, boxes and permissions from Dolibarr database.
312
-	 *	Data directories are not deleted
313
-	 *
314
-	 *	@param      string	$options    Options when enabling module ('', 'noboxes')
315
-	 *	@return     int             	1 if OK, 0 if KO
316
-	 */
317
-	public function remove($options = '')
318
-	{
319
-		$sql = array();
320
-
321
-		return $this->_remove($sql, $options);
322
-	}
315
+     *	@return     int             	1 if OK, 0 if KO
316
+     */
317
+    public function remove($options = '')
318
+    {
319
+        $sql = array();
320
+
321
+        return $this->_remove($sql, $options);
322
+    }
323 323
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modFacture.class.php 1 patch
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -35,70 +35,70 @@  discard block
 block discarded – undo
35 35
 class modFacture extends DolibarrModules
36 36
 {
37 37
 
38
-	/**
39
-	 *   Constructor. Define names, constants, directories, boxes, permissions
40
-	 *
41
-	 *   @param      DoliDB		$db      Database handler
42
-	 */
43
-	function __construct($db)
44
-	{
45
-		global $conf, $user;
46
-
47
-		$this->db = $db;
48
-		$this->numero = 30;
49
-
50
-		$this->family = "financial";
51
-		$this->module_position = '10';
52
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i', '', get_class($this));
54
-		$this->description = "Gestion des factures";
55
-
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto = 'bill';
61
-
62
-		// Data directories to create when module is enabled
63
-		$this->dirs = array("/facture/temp");
64
-
65
-		// Dependencies
66
-		$this->depends = array('always'=>"modSociete");
67
-		$this->requiredby = array("modComptabilite", "modAccounting");
68
-		$this->conflictwith = array();
69
-		$this->langfiles = array("bills", "companies", "compta", "products");
70
-		$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
71
-		$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
72
-
73
-		// Config pages
74
-		$this->config_page_url = array("facture.php");
75
-
76
-		// Constants
77
-		$this->const = array();
78
-		$r = 0;
79
-
80
-		$this->const[$r][0] = "FACTURE_ADDON";
81
-		$this->const[$r][1] = "chaine";
82
-		$this->const[$r][2] = "mod_facture_terre";
83
-		$this->const[$r][3] = 'Name of numbering numerotation rules of invoice';
84
-		$this->const[$r][4] = 0;
85
-		$r++;
86
-
87
-		$this->const[$r][0] = "FACTURE_ADDON_PDF";
88
-		$this->const[$r][1] = "chaine";
89
-		$this->const[$r][2] = "crabe";
90
-		$this->const[$r][3] = 'Name of PDF model of invoice';
91
-		$this->const[$r][4] = 0;
92
-		$r++;
93
-
94
-		$this->const[$r][0] = "FACTURE_ADDON_PDF_ODT_PATH";
95
-		$this->const[$r][1] = "chaine";
96
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/invoices";
97
-		$this->const[$r][3] = "";
98
-		$this->const[$r][4] = 0;
99
-		$r++;
100
-
101
-		/*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK";
38
+    /**
39
+     *   Constructor. Define names, constants, directories, boxes, permissions
40
+     *
41
+     *   @param      DoliDB		$db      Database handler
42
+     */
43
+    function __construct($db)
44
+    {
45
+        global $conf, $user;
46
+
47
+        $this->db = $db;
48
+        $this->numero = 30;
49
+
50
+        $this->family = "financial";
51
+        $this->module_position = '10';
52
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
54
+        $this->description = "Gestion des factures";
55
+
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        $this->picto = 'bill';
61
+
62
+        // Data directories to create when module is enabled
63
+        $this->dirs = array("/facture/temp");
64
+
65
+        // Dependencies
66
+        $this->depends = array('always'=>"modSociete");
67
+        $this->requiredby = array("modComptabilite", "modAccounting");
68
+        $this->conflictwith = array();
69
+        $this->langfiles = array("bills", "companies", "compta", "products");
70
+        $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
71
+        $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
72
+
73
+        // Config pages
74
+        $this->config_page_url = array("facture.php");
75
+
76
+        // Constants
77
+        $this->const = array();
78
+        $r = 0;
79
+
80
+        $this->const[$r][0] = "FACTURE_ADDON";
81
+        $this->const[$r][1] = "chaine";
82
+        $this->const[$r][2] = "mod_facture_terre";
83
+        $this->const[$r][3] = 'Name of numbering numerotation rules of invoice';
84
+        $this->const[$r][4] = 0;
85
+        $r++;
86
+
87
+        $this->const[$r][0] = "FACTURE_ADDON_PDF";
88
+        $this->const[$r][1] = "chaine";
89
+        $this->const[$r][2] = "crabe";
90
+        $this->const[$r][3] = 'Name of PDF model of invoice';
91
+        $this->const[$r][4] = 0;
92
+        $r++;
93
+
94
+        $this->const[$r][0] = "FACTURE_ADDON_PDF_ODT_PATH";
95
+        $this->const[$r][1] = "chaine";
96
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/invoices";
97
+        $this->const[$r][3] = "";
98
+        $this->const[$r][4] = 0;
99
+        $r++;
100
+
101
+        /*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK";
102 102
 		$this->const[$r][1] = "chaine";
103 103
 		$this->const[$r][2] = "__(Draft)__";
104 104
 		$this->const[$r][3] = 'Watermark to show on draft invoices';
@@ -106,264 +106,264 @@  discard block
 block discarded – undo
106 106
 		$r++;*/
107 107
 
108 108
 
109
-		// Boxes
110
-		//$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php'));
111
-		$this->boxes = array(
112
-				0=>array('file'=>'box_factures_imp.php', 'enabledbydefaulton'=>'Home'),
113
-				1=>array('file'=>'box_factures.php', 'enabledbydefaulton'=>'Home'),
114
-				2=>array('file'=>'box_graph_invoices_permonth.php', 'enabledbydefaulton'=>'Home')
115
-		);
116
-
117
-		// Cronjobs
118
-		$arraydate=dol_getdate(dol_now());
119
-		$datestart=dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
120
-		$this->cronjobs = array(
121
-			0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart),
122
-		);
123
-
124
-		// Permissions
125
-		$this->rights = array();
126
-		$this->rights_class = 'facture';
127
-		$r = 0;
128
-
129
-		$r++;
130
-		$this->rights[$r][0] = 11;
131
-		$this->rights[$r][1] = 'Read invoices';
132
-		$this->rights[$r][2] = 'a';
133
-		$this->rights[$r][3] = 0;
134
-		$this->rights[$r][4] = 'lire';
135
-
136
-		$r++;
137
-		$this->rights[$r][0] = 12;
138
-		$this->rights[$r][1] = 'Create and update invoices';
139
-		$this->rights[$r][2] = 'a';
140
-		$this->rights[$r][3] = 0;
141
-		$this->rights[$r][4] = 'creer';
142
-
143
-		// There is a particular permission for unvalidate because this may be not forbidden by some laws
144
-		$r++;
145
-		$this->rights[$r][0] = 13;
146
-		$this->rights[$r][1] = 'Devalidate invoices';
147
-		$this->rights[$r][2] = 'a';
148
-		$this->rights[$r][3] = 0;
109
+        // Boxes
110
+        //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php'));
111
+        $this->boxes = array(
112
+                0=>array('file'=>'box_factures_imp.php', 'enabledbydefaulton'=>'Home'),
113
+                1=>array('file'=>'box_factures.php', 'enabledbydefaulton'=>'Home'),
114
+                2=>array('file'=>'box_graph_invoices_permonth.php', 'enabledbydefaulton'=>'Home')
115
+        );
116
+
117
+        // Cronjobs
118
+        $arraydate=dol_getdate(dol_now());
119
+        $datestart=dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
120
+        $this->cronjobs = array(
121
+            0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart),
122
+        );
123
+
124
+        // Permissions
125
+        $this->rights = array();
126
+        $this->rights_class = 'facture';
127
+        $r = 0;
128
+
129
+        $r++;
130
+        $this->rights[$r][0] = 11;
131
+        $this->rights[$r][1] = 'Read invoices';
132
+        $this->rights[$r][2] = 'a';
133
+        $this->rights[$r][3] = 0;
134
+        $this->rights[$r][4] = 'lire';
135
+
136
+        $r++;
137
+        $this->rights[$r][0] = 12;
138
+        $this->rights[$r][1] = 'Create and update invoices';
139
+        $this->rights[$r][2] = 'a';
140
+        $this->rights[$r][3] = 0;
141
+        $this->rights[$r][4] = 'creer';
142
+
143
+        // There is a particular permission for unvalidate because this may be not forbidden by some laws
144
+        $r++;
145
+        $this->rights[$r][0] = 13;
146
+        $this->rights[$r][1] = 'Devalidate invoices';
147
+        $this->rights[$r][2] = 'a';
148
+        $this->rights[$r][3] = 0;
149
+        $this->rights[$r][4] = 'invoice_advance';
150
+        $this->rights[$r][5] = 'unvalidate';
151
+
152
+        $r++;
153
+        $this->rights[$r][0] = 14;
154
+        $this->rights[$r][1] = 'Validate invoices';
155
+        $this->rights[$r][2] = 'a';
156
+        $this->rights[$r][3] = 0;
157
+        $this->rights[$r][4] = 'invoice_advance';
158
+        $this->rights[$r][5] = 'validate';
159
+
160
+        $r++;
161
+        $this->rights[$r][0] = 15;
162
+        $this->rights[$r][1] = 'Send invoices by email';
163
+        $this->rights[$r][2] = 'a';
164
+        $this->rights[$r][3] = 0;
149 165
         $this->rights[$r][4] = 'invoice_advance';
150
-		$this->rights[$r][5] = 'unvalidate';
151
-
152
-		$r++;
153
-		$this->rights[$r][0] = 14;
154
-		$this->rights[$r][1] = 'Validate invoices';
155
-		$this->rights[$r][2] = 'a';
156
-		$this->rights[$r][3] = 0;
157
-		$this->rights[$r][4] = 'invoice_advance';
158
-		$this->rights[$r][5] = 'validate';
159
-
160
-		$r++;
161
-		$this->rights[$r][0] = 15;
162
-		$this->rights[$r][1] = 'Send invoices by email';
163
-		$this->rights[$r][2] = 'a';
164
-		$this->rights[$r][3] = 0;
165
-		$this->rights[$r][4] = 'invoice_advance';
166 166
         $this->rights[$r][5] = 'send';
167 167
 
168
-		$r++;
169
-		$this->rights[$r][0] = 16;
170
-		$this->rights[$r][1] = 'Issue payments on invoices';
171
-		$this->rights[$r][2] = 'a';
172
-		$this->rights[$r][3] = 0;
173
-		$this->rights[$r][4] = 'paiement';
174
-
175
-		$r++;
176
-		$this->rights[$r][0] = 19;
177
-		$this->rights[$r][1] = 'Delete invoices';
178
-		$this->rights[$r][2] = 'a';
179
-		$this->rights[$r][3] = 0;
180
-		$this->rights[$r][4] = 'supprimer';
181
-
182
-		$r++;
183
-		$this->rights[$r][0] = 1321;
184
-		$this->rights[$r][1] = 'Export customer invoices, attributes and payments';
185
-		$this->rights[$r][2] = 'r';
186
-		$this->rights[$r][3] = 0;
187
-		$this->rights[$r][4] = 'facture';
188
-		$this->rights[$r][5] = 'export';
189
-
190
-		$r++;
191
-		$this->rights[$r][0] = 1322;
192
-		$this->rights[$r][1] = 'Re-open a fully paid invoice';
193
-		$this->rights[$r][2] = 'r';
194
-		$this->rights[$r][3] = 0;
195
-		$this->rights[$r][4] = 'invoice_advance';
196
-		$this->rights[$r][5] = 'reopen';
197
-
198
-
199
-		// Menus
200
-		//-------
201
-		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
202
-
203
-
204
-		// Exports
205
-		//--------
206
-		$r = 1;
207
-
208
-		$this->export_code[$r] = $this->rights_class.'_'.$r;
209
-		$this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
210
-		$this->export_icon[$r] = 'invoice';
211
-		$this->export_permission[$r] = array(array("facture", "facture", "export", "other"));
212
-		$this->export_fields_array[$r] = array(
213
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
214
-			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
215
-			's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
216
-			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
217
-			'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
218
-			'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus',
219
-			'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
220
-			'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
221
-			'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",
222
-			'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',
223
-			'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',
224
-			'p.accountancy_code_sell'=>'ProductAccountancySellCode'
225
-		);
226
-		$this->export_TypeFields_array[$r] = array(
227
-			's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
228
-			's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
229
-			'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
230
-			'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'none.rest'=>"NumericCompute", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric',
231
-			'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
232
-			'pj.ref'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
233
-			'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
234
-			'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text',
235
-			'p.accountancy_code_sell'=>'Text'
236
-		);
237
-		$this->export_entities_array[$r] = array(
238
-			's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
239
-			's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
240
-			's.tva_intra'=>'company', 'pj.ref'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",
241
-			'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",
242
-			'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line',
243
-			'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_sell'=>'product',
244
-			'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user'
245
-		);
246
-		$this->export_special_array[$r] = array('none.rest'=>'getRemainToPay');
247
-		$this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
248
-		$keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';
249
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
250
-		$keyforselect = 'facturedet'; $keyforelement = 'invoice_line'; $keyforaliasextra = 'extra2';
251
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
252
-		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3';
253
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
254
-		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
255
-		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
256
-		if (empty($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';
257
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
258
-		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture as f';
259
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
260
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid';
261
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid';
262
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object';
263
-		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facturedet as fd';
264
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object';
265
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
266
-		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
267
-		$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
268
-		$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
269
-		if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
270
-		$r++;
271
-
272
-		$this->export_code[$r] = $this->rights_class.'_'.$r;
273
-		$this->export_label[$r] = 'CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found)
274
-		$this->export_icon[$r] = 'invoice';
275
-		$this->export_permission[$r] = array(array("facture", "facture", "export"));
276
-		$this->export_fields_array[$r] = array(
277
-			's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
278
-			's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
279
-			's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
280
-			'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef",  'f.ref_client'=>'RefCustomer',
281
-			'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
282
-			'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus',
283
-			'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
284
-			'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef',
285
-			'p.amount'=>'AmountPayment', 'pf.amount'=>'AmountPaymentDistributedOnInvoice', 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber',
286
-			'pt.code'=>'CodePaymentMode', 'pt.libelle'=>'LabelPaymentMode', 'p.note'=>'PaymentNote', 'p.fk_bank'=>'IdTransaction', 'ba.ref'=>'AccountRef'
287
-		);
288
-		$this->export_TypeFields_array[$r] = array(
289
-			's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
290
-			's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
291
-			'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
292
-			'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'none.rest'=>'NumericCompute', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status',
293
-			'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
294
-			'pj.ref'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric',
295
-			'p.fk_bank'=>'Numeric', 'p.note'=>'Text', 'pt.code'=>'Text', 'pt.libelle'=>'text', 'ba.ref'=>'Text'
296
-		);
297
-		$this->export_entities_array[$r] = array(
298
-			's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
299
-			's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
300
-			's.tva_intra'=>'company', 'pj.ref'=>'project', 'p.rowid'=>'payment', 'p.ref'=>'payment', 'p.amount'=>'payment', 'pf.amount'=>'payment', 'p.datep'=>'payment',
301
-			'p.num_paiement'=>'payment', 'pt.code'=>'payment', 'pt.libelle'=>'payment', 'p.note'=>'payment', 'f.fk_user_author'=>'user', 'uc.login'=>'user',
302
-			'f.fk_user_valid'=>'user', 'uv.login'=>'user', 'p.fk_bank'=>'account', 'ba.ref'=>'account'
303
-		);
304
-		$this->export_special_array[$r] = array('none.rest'=>'getRemainToPay');
305
-		$this->export_dependencies_array[$r] = array('payment'=>'p.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
306
-		$keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';
307
-		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
308
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
309
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
310
-		if (empty($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';
311
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
312
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f';
313
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
314
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid';
315
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid';
316
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object';
317
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
318
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid';
319
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement';
320
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank';
321
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
322
-		$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
323
-		$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('invoice').')';
324
-		if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
325
-		$r++;
326
-	}
327
-
328
-
329
-	/**
330
-	 *		Function called when module is enabled.
331
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
332
-	 *		It also creates data directories
333
-	 *
168
+        $r++;
169
+        $this->rights[$r][0] = 16;
170
+        $this->rights[$r][1] = 'Issue payments on invoices';
171
+        $this->rights[$r][2] = 'a';
172
+        $this->rights[$r][3] = 0;
173
+        $this->rights[$r][4] = 'paiement';
174
+
175
+        $r++;
176
+        $this->rights[$r][0] = 19;
177
+        $this->rights[$r][1] = 'Delete invoices';
178
+        $this->rights[$r][2] = 'a';
179
+        $this->rights[$r][3] = 0;
180
+        $this->rights[$r][4] = 'supprimer';
181
+
182
+        $r++;
183
+        $this->rights[$r][0] = 1321;
184
+        $this->rights[$r][1] = 'Export customer invoices, attributes and payments';
185
+        $this->rights[$r][2] = 'r';
186
+        $this->rights[$r][3] = 0;
187
+        $this->rights[$r][4] = 'facture';
188
+        $this->rights[$r][5] = 'export';
189
+
190
+        $r++;
191
+        $this->rights[$r][0] = 1322;
192
+        $this->rights[$r][1] = 'Re-open a fully paid invoice';
193
+        $this->rights[$r][2] = 'r';
194
+        $this->rights[$r][3] = 0;
195
+        $this->rights[$r][4] = 'invoice_advance';
196
+        $this->rights[$r][5] = 'reopen';
197
+
198
+
199
+        // Menus
200
+        //-------
201
+        $this->menu = 1; // This module add menu entries. They are coded into menu manager.
202
+
203
+
204
+        // Exports
205
+        //--------
206
+        $r = 1;
207
+
208
+        $this->export_code[$r] = $this->rights_class.'_'.$r;
209
+        $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
210
+        $this->export_icon[$r] = 'invoice';
211
+        $this->export_permission[$r] = array(array("facture", "facture", "export", "other"));
212
+        $this->export_fields_array[$r] = array(
213
+            's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
214
+            's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
215
+            's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
216
+            'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
217
+            'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
218
+            'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus',
219
+            'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
220
+            'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
221
+            'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",
222
+            'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',
223
+            'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',
224
+            'p.accountancy_code_sell'=>'ProductAccountancySellCode'
225
+        );
226
+        $this->export_TypeFields_array[$r] = array(
227
+            's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
228
+            's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
229
+            'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
230
+            'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'none.rest'=>"NumericCompute", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric',
231
+            'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
232
+            'pj.ref'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
233
+            'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
234
+            'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text',
235
+            'p.accountancy_code_sell'=>'Text'
236
+        );
237
+        $this->export_entities_array[$r] = array(
238
+            's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
239
+            's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
240
+            's.tva_intra'=>'company', 'pj.ref'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",
241
+            'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",
242
+            'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line',
243
+            'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_sell'=>'product',
244
+            'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user'
245
+        );
246
+        $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay');
247
+        $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
248
+        $keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';
249
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
250
+        $keyforselect = 'facturedet'; $keyforelement = 'invoice_line'; $keyforaliasextra = 'extra2';
251
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
252
+        $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3';
253
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
254
+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
255
+        $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'societe as s';
256
+        if (empty($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';
257
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
258
+        $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture as f';
259
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
260
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid';
261
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid';
262
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object';
263
+        $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facturedet as fd';
264
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object';
265
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
266
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
267
+        $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
268
+        $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
269
+        if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
270
+        $r++;
271
+
272
+        $this->export_code[$r] = $this->rights_class.'_'.$r;
273
+        $this->export_label[$r] = 'CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found)
274
+        $this->export_icon[$r] = 'invoice';
275
+        $this->export_permission[$r] = array(array("facture", "facture", "export"));
276
+        $this->export_fields_array[$r] = array(
277
+            's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
278
+            's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
279
+            's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
280
+            'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef",  'f.ref_client'=>'RefCustomer',
281
+            'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
282
+            'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus',
283
+            'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
284
+            'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef',
285
+            'p.amount'=>'AmountPayment', 'pf.amount'=>'AmountPaymentDistributedOnInvoice', 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber',
286
+            'pt.code'=>'CodePaymentMode', 'pt.libelle'=>'LabelPaymentMode', 'p.note'=>'PaymentNote', 'p.fk_bank'=>'IdTransaction', 'ba.ref'=>'AccountRef'
287
+        );
288
+        $this->export_TypeFields_array[$r] = array(
289
+            's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
290
+            's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
291
+            'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
292
+            'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'none.rest'=>'NumericCompute', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status',
293
+            'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
294
+            'pj.ref'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric',
295
+            'p.fk_bank'=>'Numeric', 'p.note'=>'Text', 'pt.code'=>'Text', 'pt.libelle'=>'text', 'ba.ref'=>'Text'
296
+        );
297
+        $this->export_entities_array[$r] = array(
298
+            's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
299
+            's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
300
+            's.tva_intra'=>'company', 'pj.ref'=>'project', 'p.rowid'=>'payment', 'p.ref'=>'payment', 'p.amount'=>'payment', 'pf.amount'=>'payment', 'p.datep'=>'payment',
301
+            'p.num_paiement'=>'payment', 'pt.code'=>'payment', 'pt.libelle'=>'payment', 'p.note'=>'payment', 'f.fk_user_author'=>'user', 'uc.login'=>'user',
302
+            'f.fk_user_valid'=>'user', 'uv.login'=>'user', 'p.fk_bank'=>'account', 'ba.ref'=>'account'
303
+        );
304
+        $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay');
305
+        $this->export_dependencies_array[$r] = array('payment'=>'p.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
306
+        $keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';
307
+        include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
308
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
309
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'societe as s';
310
+        if (empty($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';
311
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
312
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f';
313
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
314
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid';
315
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid';
316
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object';
317
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
318
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid';
319
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement';
320
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank';
321
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
322
+        $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
323
+        $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('invoice').')';
324
+        if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
325
+        $r++;
326
+    }
327
+
328
+
329
+    /**
330
+     *		Function called when module is enabled.
331
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
332
+     *		It also creates data directories
333
+     *
334 334
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
335
-	 *      @return     int             	1 if OK, 0 if KO
336
-	 */
337
-	function init($options = '')
338
-	{
339
-		global $conf, $langs;
340
-
341
-		// Remove permissions and default values
342
-		$this->remove($options);
343
-
344
-		//ODT template
345
-		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt';
346
-		$dirodt = DOL_DATA_ROOT.'/doctemplates/invoices';
347
-		$dest = $dirodt.'/template_invoice.odt';
348
-
349
-		if (file_exists($src) && !file_exists($dest))
350
-		{
351
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
352
-			dol_mkdir($dirodt);
353
-			$result = dol_copy($src, $dest, 0, 0);
354
-			if ($result < 0)
355
-			{
356
-				$langs->load("errors");
357
-				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
358
-				return 0;
359
-			}
360
-		}
361
-
362
-		$sql = array(
363
-				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'invoice' AND entity = ".$conf->entity,
364
-				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','invoice',".$conf->entity.")"
365
-		);
366
-
367
-		return $this->_init($sql, $options);
368
-	}
335
+     *      @return     int             	1 if OK, 0 if KO
336
+     */
337
+    function init($options = '')
338
+    {
339
+        global $conf, $langs;
340
+
341
+        // Remove permissions and default values
342
+        $this->remove($options);
343
+
344
+        //ODT template
345
+        $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt';
346
+        $dirodt = DOL_DATA_ROOT.'/doctemplates/invoices';
347
+        $dest = $dirodt.'/template_invoice.odt';
348
+
349
+        if (file_exists($src) && !file_exists($dest))
350
+        {
351
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
352
+            dol_mkdir($dirodt);
353
+            $result = dol_copy($src, $dest, 0, 0);
354
+            if ($result < 0)
355
+            {
356
+                $langs->load("errors");
357
+                $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
358
+                return 0;
359
+            }
360
+        }
361
+
362
+        $sql = array(
363
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'invoice' AND entity = ".$conf->entity,
364
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','invoice',".$conf->entity.")"
365
+        );
366
+
367
+        return $this->_init($sql, $options);
368
+    }
369 369
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/oauth/stripetest_oauthcallback.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 // Setup the credentials for the requests
67 67
 $credentials = new Credentials(
68 68
     $conf->global->OAUTH_STRIPE_TEST_ID,
69
-	$conf->global->STRIPE_TEST_SECRET_KEY,
69
+    $conf->global->STRIPE_TEST_SECRET_KEY,
70 70
     $currentUri->getAbsoluteUri()
71 71
 );
72 72
 
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 
110 110
 if (! empty($_GET['code']))     // We are coming from oauth provider page
111 111
 {
112
-	// We should have
113
-	//$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
112
+    // We should have
113
+    //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
114 114
 
115
-	dol_syslog("We are coming from the oauth provider page");
115
+    dol_syslog("We are coming from the oauth provider page");
116 116
     //llxHeader('',$langs->trans("OAuthSetup"));
117 117
 
118 118
     //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
     else
161 161
     {
162 162
         //$url = $apiService->getAuthorizationUri();      // Parameter state will be randomly generated
163
-    	//https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write
164
-    	$url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->OAUTH_STRIPE_TEST_ID.'&scope=read_write';
163
+        //https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write
164
+        $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->OAUTH_STRIPE_TEST_ID.'&scope=read_write';
165 165
     }
166 166
 
167 167
     // we go on oauth provider authorization page
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/oauth/google_oauthcallback.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,8 +109,8 @@
 block discarded – undo
109 109
 
110 110
 if (! empty($_GET['code']))     // We are coming from oauth provider page
111 111
 {
112
-	dol_syslog("We are coming from the oauth provider page");
113
-	//llxHeader('',$langs->trans("OAuthSetup"));
112
+    dol_syslog("We are coming from the oauth provider page");
113
+    //llxHeader('',$langs->trans("OAuthSetup"));
114 114
 
115 115
     //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
116 116
     //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/oauth/github_oauthcallback.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -106,10 +106,10 @@
 block discarded – undo
106 106
 
107 107
 if (! empty($_GET['code']))     // We are coming from oauth provider page
108 108
 {
109
-	// We should have
110
-	//$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
109
+    // We should have
110
+    //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
111 111
 
112
-	dol_syslog("We are coming from the oauth provider page");
112
+    dol_syslog("We are coming from the oauth provider page");
113 113
     //llxHeader('',$langs->trans("OAuthSetup"));
114 114
 
115 115
     //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/printing/modules_printing.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
     public $db;
38 38
 
39 39
     /**
40
-	 * @var string Error code (or message)
41
-	 */
42
-	public $error='';
40
+     * @var string Error code (or message)
41
+     */
42
+    public $error='';
43 43
 
44 44
 
45 45
     /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *  @param  DoliDB  $db                 Database handler
59 59
      *  @param  integer  $maxfilenamelength  Max length of value to show
60 60
      *  @return array                       List of drivers
61
-    */
61
+     */
62 62
     static function listDrivers($db,$maxfilenamelength=0)
63 63
     {
64 64
         global $conf;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/printing/printgcp.modules.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -89,47 +89,47 @@
 block discarded – undo
89 89
             );
90 90
         } else {
91 91
 
92
-        	$this->google_id = $conf->global->OAUTH_GOOGLE_ID;
93
-        	$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
94
-        	// Token storage
95
-        	$storage = new DoliStorage($this->db, $this->conf);
96
-        	//$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE);
97
-        	// Setup the credentials for the requests
98
-        	$credentials = new Credentials(
99
-            	$this->google_id,
100
-            	$this->google_secret,
101
-            	$urlwithroot.'/core/modules/oauth/google_oauthcallback.php'
102
-        	);
103
-        	$access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken');
104
-        	$serviceFactory = new \OAuth\ServiceFactory();
105
-        	$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
106
-        	$token_ok=true;
107
-        	try {
108
-            	$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
109
-        	} catch (Exception $e) {
110
-            	$this->errors[] = $e->getMessage();
111
-            	$token_ok = false;
112
-        	}
113
-        	//var_dump($this->errors);exit;
114
-
115
-        	$expire = false;
116
-        	// Is token expired or will token expire in the next 30 seconds
117
-        	if ($token_ok) {
118
-            	$expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
119
-        	}
120
-
121
-        	// Token expired so we refresh it
122
-        	if ($token_ok && $expire) {
123
-            	try {
124
-                	// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
125
-                	$refreshtoken = $token->getRefreshToken();
126
-                	$token = $apiService->refreshAccessToken($token);
127
-                	$token->setRefreshToken($refreshtoken);
128
-                	$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
129
-            	} catch (Exception $e) {
130
-                	$this->errors[] = $e->getMessage();
131
-            	}
132
-        	}
92
+            $this->google_id = $conf->global->OAUTH_GOOGLE_ID;
93
+            $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
94
+            // Token storage
95
+            $storage = new DoliStorage($this->db, $this->conf);
96
+            //$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE);
97
+            // Setup the credentials for the requests
98
+            $credentials = new Credentials(
99
+                $this->google_id,
100
+                $this->google_secret,
101
+                $urlwithroot.'/core/modules/oauth/google_oauthcallback.php'
102
+            );
103
+            $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken');
104
+            $serviceFactory = new \OAuth\ServiceFactory();
105
+            $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
106
+            $token_ok=true;
107
+            try {
108
+                $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
109
+            } catch (Exception $e) {
110
+                $this->errors[] = $e->getMessage();
111
+                $token_ok = false;
112
+            }
113
+            //var_dump($this->errors);exit;
114
+
115
+            $expire = false;
116
+            // Is token expired or will token expire in the next 30 seconds
117
+            if ($token_ok) {
118
+                $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
119
+            }
120
+
121
+            // Token expired so we refresh it
122
+            if ($token_ok && $expire) {
123
+                try {
124
+                    // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
125
+                    $refreshtoken = $token->getRefreshToken();
126
+                    $token = $apiService->refreshAccessToken($token);
127
+                    $token->setRefreshToken($refreshtoken);
128
+                    $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
129
+                } catch (Exception $e) {
130
+                    $this->errors[] = $e->getMessage();
131
+                }
132
+            }
133 133
             if ($this->google_id != '' && $this->google_secret != '') {
134 134
                 $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
135 135
                 $this->conf[] = array(
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/printing/printipp.modules.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
             $obj = $this->db->fetch_object($result);
110 110
             if ($obj)
111 111
             {
112
-            	dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id);
112
+                dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id);
113 113
                 $ipp->setPrinterURI($obj->printer_id);
114 114
             }
115 115
             else
Please login to merge, or discard this patch.