Passed
Push — master ( 8f7a8e...7e4a07 )
by Alxarafe
20:11
created
dolibarr/htdocs/margin/lib/margins.lib.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@
 block discarded – undo
73 73
 
74 74
     if ($user->rights->societe->lire) {
75 75
         $head[$h][0] = BASE_URI . '?controller=margin&method=customerMargins';
76
-		$head[$h][1] = $langs->trans("CustomerMargins");
77
-		$head[$h][2] = 'customerMargins';
78
-		$h++;
79
-	}
76
+        $head[$h][1] = $langs->trans("CustomerMargins");
77
+        $head[$h][2] = 'customerMargins';
78
+        $h++;
79
+    }
80 80
 
81 81
     if ($user->rights->margins->read->all) {
82 82
         $title = 'UserMargins';
Please login to merge, or discard this patch.
dolibarr/htdocs/master.inc.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -68,33 +68,33 @@  discard block
 block discarded – undo
68 68
 $conf->file->dol_url_root				= array('main' => (string) DOL_URL_ROOT);									// Define array of url root path ('' or '/dolibarr')
69 69
 if (! empty($dolibarr_main_document_root_alt))
70 70
 {
71
-	// dolibarr_main_document_root_alt can contains several directories
72
-	$values=preg_split('/[;,]/',$dolibarr_main_document_root_alt);
73
-	$i=0;
71
+    // dolibarr_main_document_root_alt can contains several directories
72
+    $values=preg_split('/[;,]/',$dolibarr_main_document_root_alt);
73
+    $i=0;
74 74
     foreach ($values as $value)
75 75
         $conf->file->dol_document_root['alt' . ($i++)] = (string)$value;
76
-	$values=preg_split('/[;,]/',$dolibarr_main_url_root_alt);
77
-	$i=0;
78
-	foreach($values as $value)
79
-	{
80
-		if (preg_match('/^http(s)?:/',$value))
81
-		{
82
-			// Show error message
83
-			$correct_value = str_replace($dolibarr_main_url_root, '', $value);
84
-			print '<b>Error:</b><br>'."\n";
85
-			print 'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'."\n";
86
-			print 'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'."\n";
87
-			print 'Value found: '.$value.'<br>'."\n";
88
-			print 'Should be replaced by: '.$correct_value.'<br>'."\n";
89
-			print "Or something like following examples:<br>\n";
90
-			print "\"/extensions\"<br>\n";
91
-			print "\"/extensions1,/extensions2,...\"<br>\n";
92
-			print "\"/../extensions\"<br>\n";
93
-			print "\"/custom\"<br>\n";
94
-			exit;
95
-		}
96
-		$conf->file->dol_url_root['alt'.($i++)]=(string) $value;
97
-	}
76
+    $values=preg_split('/[;,]/',$dolibarr_main_url_root_alt);
77
+    $i=0;
78
+    foreach($values as $value)
79
+    {
80
+        if (preg_match('/^http(s)?:/',$value))
81
+        {
82
+            // Show error message
83
+            $correct_value = str_replace($dolibarr_main_url_root, '', $value);
84
+            print '<b>Error:</b><br>'."\n";
85
+            print 'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'."\n";
86
+            print 'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'."\n";
87
+            print 'Value found: '.$value.'<br>'."\n";
88
+            print 'Should be replaced by: '.$correct_value.'<br>'."\n";
89
+            print "Or something like following examples:<br>\n";
90
+            print "\"/extensions\"<br>\n";
91
+            print "\"/extensions1,/extensions2,...\"<br>\n";
92
+            print "\"/../extensions\"<br>\n";
93
+            print "\"/custom\"<br>\n";
94
+            exit;
95
+        }
96
+        $conf->file->dol_url_root['alt'.($i++)]=(string) $value;
97
+    }
98 98
 }
99 99
 
100 100
 // Chargement des includes principaux de librairies communes
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
  */
109 109
 if (! defined('NOREQUIRETRAN'))
110 110
 {
111
-	$langs = new Translate('',$conf);	// Must be after reading conf
111
+    $langs = new Translate('',$conf);	// Must be after reading conf
112 112
 }
113 113
 
114 114
 /*
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 {
119 119
     $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
120 120
 
121
-	if ($db->error)
122
-	{
123
-		dol_print_error($db,"host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
124
-		exit;
125
-	}
121
+    if ($db->error)
122
+    {
123
+        dol_print_error($db,"host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
124
+        exit;
125
+    }
126 126
 }
127 127
 
128 128
 // Now database connexion is known, so we can forget password
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
  */
135 135
 if (! defined('NOREQUIREUSER'))
136 136
 {
137
-	$user = new User($db);
137
+    $user = new User($db);
138 138
 }
139 139
 
140 140
 /*
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 // By default conf->entity is 1, but we change this if we ask another value.
146 146
 if (session_id() && ! empty($_SESSION["dol_entity"]))			// Entity inside an opened session
147 147
 {
148
-	$conf->entity = $_SESSION["dol_entity"];
148
+    $conf->entity = $_SESSION["dol_entity"];
149 149
 }
150 150
 else if (! empty($_ENV["dol_entity"]))							// Entity inside a CLI script
151 151
 {
152
-	$conf->entity = $_ENV["dol_entity"];
152
+    $conf->entity = $_ENV["dol_entity"];
153 153
 }
154 154
 else if (isset($_POST["loginfunction"]) && GETPOST("entity",'int'))	// Just after a login page
155 155
 {
156
-	$conf->entity = GETPOST("entity",'int');
156
+    $conf->entity = GETPOST("entity",'int');
157 157
 }
158 158
 else if (defined('DOLENTITY') && is_numeric(DOLENTITY))			// For public page with MultiCompany module
159 159
 {
160
-	$conf->entity = DOLENTITY;
160
+    $conf->entity = DOLENTITY;
161 161
 }
162 162
 
163 163
 // Sanitize entity
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 
166 166
 if (! defined('NOREQUIREDB'))
167 167
 {
168
-	//print "Will work with data into entity instance number '".$conf->entity."'";
168
+    //print "Will work with data into entity instance number '".$conf->entity."'";
169 169
 
170
-	// Here we read database (llx_const table) and define $conf->global->XXX var.
171
-	$conf->setValues($db);
170
+    // Here we read database (llx_const table) and define $conf->global->XXX var.
171
+    $conf->setValues($db);
172 172
 }
173 173
 
174 174
 // Overwrite database value
175 175
 if (! empty($conf->file->mailing_limit_sendbyweb))
176 176
 {
177
-	$conf->global->MAILING_LIMIT_SENDBYWEB = $conf->file->mailing_limit_sendbyweb;
177
+    $conf->global->MAILING_LIMIT_SENDBYWEB = $conf->file->mailing_limit_sendbyweb;
178 178
 }
179 179
 if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
180 180
 {
@@ -192,41 +192,41 @@  discard block
 block discarded – undo
192 192
 // If software has been locked. Only login $conf->global->MAIN_ONLY_LOGIN_ALLOWED is allowed.
193 193
 if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
194 194
 {
195
-	$ok=0;
196
-	if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) $ok=1;	// We let working pages if not logged and inside a web browser (login form, to allow login by admin)
197
-	elseif (isset($_POST["username"]) && $_POST["username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1;				// We let working pages that is a login submission (login submit, to allow login by admin)
198
-	elseif (defined('NOREQUIREDB'))   $ok=1;				// We let working pages that don't need database access (xxx.css.php)
199
-	elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) $ok=1;	// We let working pages that ask to work even if only login enabled (logout.php)
200
-	elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1;	// We let working if user is allowed admin
201
-	if (! $ok)
202
-	{
203
-		if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED)
204
-		{
205
-			print 'Sorry, your application is offline.'."\n";
206
-			print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n";
195
+    $ok=0;
196
+    if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) $ok=1;	// We let working pages if not logged and inside a web browser (login form, to allow login by admin)
197
+    elseif (isset($_POST["username"]) && $_POST["username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1;				// We let working pages that is a login submission (login submit, to allow login by admin)
198
+    elseif (defined('NOREQUIREDB'))   $ok=1;				// We let working pages that don't need database access (xxx.css.php)
199
+    elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) $ok=1;	// We let working pages that ask to work even if only login enabled (logout.php)
200
+    elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1;	// We let working if user is allowed admin
201
+    if (! $ok)
202
+    {
203
+        if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED)
204
+        {
205
+            print 'Sorry, your application is offline.'."\n";
206
+            print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n";
207 207
             $nexturl = BASE_URI . '?controller=user&method=logout';
208
-			print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n";
209
-		}
210
-		else
211
-		{
212
-			print 'Sorry, your application is offline. Only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n";
208
+            print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n";
209
+        }
210
+        else
211
+        {
212
+            print 'Sorry, your application is offline. Only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n";
213 213
             $nexturl = BASE_URI . '/';
214
-			print 'Please try later or <a href="'.$nexturl.'">click here to change login user</a>...'."\n";
215
-		}
216
-		exit;
217
-	}
214
+            print 'Please try later or <a href="'.$nexturl.'">click here to change login user</a>...'."\n";
215
+        }
216
+        exit;
217
+    }
218 218
 }
219 219
 
220 220
 // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr.
221 221
 if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
222 222
 {
223
-	require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php';
223
+    require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php';
224 224
 
225
-	$mysoc=new Societe($db);
226
-	$mysoc->setMysoc($conf);
225
+    $mysoc=new Societe($db);
226
+    $mysoc->setMysoc($conf);
227 227
 
228
-	// For some countries, we need to invert our address with customer address
229
-	if ($mysoc->country_code == 'DE' && ! isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT=1;
228
+    // For some countries, we need to invert our address with customer address
229
+    if ($mysoc->country_code == 'DE' && ! isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT=1;
230 230
 }
231 231
 
232 232
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/product.lib.php 1 patch
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -34,88 +34,88 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function product_prepare_head($object)
36 36
 {
37
-	global $db, $langs, $conf, $user;
38
-	$langs->load("products");
37
+    global $db, $langs, $conf, $user;
38
+    $langs->load("products");
39 39
 
40
-	$h = 0;
41
-	$head = array();
40
+    $h = 0;
41
+    $head = array();
42 42
 
43 43
     $head[$h][0] = BASE_URI . "?controller=product&method=card&id=" . $object->id;
44
-	$head[$h][1] = $langs->trans("Card");
45
-	$head[$h][2] = 'card';
46
-	$h++;
44
+    $head[$h][1] = $langs->trans("Card");
45
+    $head[$h][2] = 'card';
46
+    $h++;
47 47
 
48
-	if (! empty($object->status))
49
-	{
48
+    if (! empty($object->status))
49
+    {
50 50
         $head[$h][0] = BASE_URI . "?controller=product&method=price&id=" . $object->id;
51
-    	$head[$h][1] = $langs->trans("SellingPrices");
52
-    	$head[$h][2] = 'price';
53
-    	$h++;
54
-	}
55
-
56
-	if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status)))   // If margin is on and product on sell, we may need the cost price even if product os not on purchase
57
-	{
58
-    	if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
59
-    	|| (! empty($conf->margin->enabled) && $user->rights->margin->liretous)
60
-    	)
61
-    	{
51
+        $head[$h][1] = $langs->trans("SellingPrices");
52
+        $head[$h][2] = 'price';
53
+        $h++;
54
+    }
55
+
56
+    if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status)))   // If margin is on and product on sell, we may need the cost price even if product os not on purchase
57
+    {
58
+        if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
59
+        || (! empty($conf->margin->enabled) && $user->rights->margin->liretous)
60
+        )
61
+        {
62 62
             $head[$h][0] = BASE_URI . "?controller=product&method=fournisseurs&id=" . $object->id;
63
-    		$head[$h][1] = $langs->trans("BuyingPrices");
64
-    		$head[$h][2] = 'suppliers';
65
-    		$h++;
66
-    	}
67
-	}
68
-
69
-	// Multilangs
70
-	if (! empty($conf->global->MAIN_MULTILANGS))
71
-	{
63
+            $head[$h][1] = $langs->trans("BuyingPrices");
64
+            $head[$h][2] = 'suppliers';
65
+            $h++;
66
+        }
67
+    }
68
+
69
+    // Multilangs
70
+    if (! empty($conf->global->MAIN_MULTILANGS))
71
+    {
72 72
         $head[$h][0] = BASE_URI . "?controller=product&method=traduction&id=" . $object->id;
73
-		$head[$h][1] = $langs->trans("Translation");
74
-		$head[$h][2] = 'translation';
75
-		$h++;
76
-	}
77
-
78
-	// Sub products
79
-	if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
80
-	{
73
+        $head[$h][1] = $langs->trans("Translation");
74
+        $head[$h][2] = 'translation';
75
+        $h++;
76
+    }
77
+
78
+    // Sub products
79
+    if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
80
+    {
81 81
         $head[$h][0] = BASE_URI . "?controller=product/composition&method=card&id=" . $object->id;
82
-		$head[$h][1] = $langs->trans('AssociatedProducts');
82
+        $head[$h][1] = $langs->trans('AssociatedProducts');
83 83
 
84
-		$nbFatherAndChild = $object->hasFatherOrChild();
85
-		if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>';
86
-		$head[$h][2] = 'subproduct';
87
-		$h++;
88
-	}
84
+        $nbFatherAndChild = $object->hasFatherOrChild();
85
+        if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>';
86
+        $head[$h][2] = 'subproduct';
87
+        $h++;
88
+    }
89 89
 
90 90
     $head[$h][0] = BASE_URI . "?controller=product/stats&method=card&id=" . $object->id;
91
-	$head[$h][1] = $langs->trans('Statistics');
92
-	$head[$h][2] = 'stats';
93
-	$h++;
91
+    $head[$h][1] = $langs->trans('Statistics');
92
+    $head[$h][2] = 'stats';
93
+    $h++;
94 94
 
95 95
     $head[$h][0] = BASE_URI . "?controller=product/stats&method=facture&showmessage=1&id=" . $object->id;
96
-	$head[$h][1] = $langs->trans('Referers');
97
-	$head[$h][2] = 'referers';
98
-	$h++;
96
+    $head[$h][1] = $langs->trans('Referers');
97
+    $head[$h][2] = 'referers';
98
+    $h++;
99 99
 
100
-	if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
100
+    if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
101 101
 
102
-		global $db;
102
+        global $db;
103 103
 
104
-		require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
104
+        require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
105 105
 
106
-		$prodcomb = new ProductCombination($db);
106
+        $prodcomb = new ProductCombination($db);
107 107
 
108
-		if ($prodcomb->fetchByFkProductChild($object->id) == -1)
109
-		{
108
+        if ($prodcomb->fetchByFkProductChild($object->id) == -1)
109
+        {
110 110
             $head[$h][0] = BASE_URI . "?controller=variants&method=combinations&id=" . $object->id;
111
-			$head[$h][1] = $langs->trans('ProductCombinations');
112
-			$head[$h][2] = 'combinations';
113
-			$nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
111
+            $head[$h][1] = $langs->trans('ProductCombinations');
112
+            $head[$h][2] = 'combinations';
113
+            $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
114 114
             if ($nbVariant > 0) $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>';
115
-		}
115
+        }
116 116
 
117
-		$h++;
118
-	}
117
+        $h++;
118
+    }
119 119
 
120 120
     if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES)))    // If physical product we can stock (or service with option)
121 121
     {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     }
149 149
 
150 150
     // Attachments
151
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
151
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
152 152
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
153 153
     if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
154 154
     if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
     }
161 161
     $nbLinks=Link::count($db, $object->element, $object->id);
162 162
     $head[$h][0] = BASE_URI . '?controller=product&method=document&id=' . $object->id;
163
-	$head[$h][1] = $langs->trans('Documents');
164
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
165
-	$head[$h][2] = 'documents';
166
-	$h++;
163
+    $head[$h][1] = $langs->trans('Documents');
164
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
165
+    $head[$h][2] = 'documents';
166
+    $h++;
167 167
 
168 168
     complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove');
169 169
 
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
     $head[$h][1] = $langs->trans("Events");
173 173
     if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
174 174
     {
175
-    	$head[$h][1].= '/';
176
-    	$head[$h][1].= $langs->trans("Agenda");
175
+        $head[$h][1].= '/';
176
+        $head[$h][1].= $langs->trans("Agenda");
177 177
     }
178 178
     $head[$h][2] = 'agenda';
179 179
     $h++;
180 180
 
181
-	return $head;
181
+    return $head;
182 182
 }
183 183
 
184 184
 /**
@@ -200,19 +200,19 @@  discard block
 block discarded – undo
200 200
     $head[$h][0] = BASE_URI . "?controller=product/stock&method=productlot_card&id=" . $object->id;
201 201
     $head[$h][1] = $langs->trans("Card");
202 202
     $head[$h][2] = 'card';
203
-	$h++;
203
+    $h++;
204 204
 
205
-	// Attachments
206
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
205
+    // Attachments
206
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
207 207
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
208 208
     $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
209 209
     $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
210 210
     $nbLinks=Link::count($db, $object->element, $object->id);
211 211
     $head[$h][0] = BASE_URI . "?controller=product/stock&method=productlot_document&id=" . $object->id;
212
-	$head[$h][1] = $langs->trans("Documents");
213
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
212
+    $head[$h][1] = $langs->trans("Documents");
213
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
214 214
     $head[$h][2] = 'documents';
215
-	$h++;
215
+    $h++;
216 216
 
217 217
     // Show more tabs from modules
218 218
     // Entries must be declared in modules descriptor with line
@@ -242,40 +242,40 @@  discard block
 block discarded – undo
242 242
 */
243 243
 function product_admin_prepare_head()
244 244
 {
245
-	global $langs, $conf, $user;
245
+    global $langs, $conf, $user;
246 246
 
247
-	$h = 0;
248
-	$head = array();
247
+    $h = 0;
248
+    $head = array();
249 249
 
250 250
     $head[$h][0] = BASE_URI . "?controller=product/admin&method=product";
251
-	$head[$h][1] = $langs->trans('Parameters');
252
-	$head[$h][2] = 'general';
253
-	$h++;
251
+    $head[$h][1] = $langs->trans('Parameters');
252
+    $head[$h][2] = 'general';
253
+    $h++;
254 254
 
255
-	if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
256
-	{
257
-		$head[$h] = array(
255
+    if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
256
+    {
257
+        $head[$h] = array(
258 258
             0 => BASE_URI . "?controller=product/admin&method=price_rules",
259
-			1 => $langs->trans('MultipriceRules'),
260
-			2 => 'generator'
261
-		);
262
-		$h++;
263
-	}
264
-
265
-	// Show more tabs from modules
266
-	// Entries must be declared in modules descriptor with line
259
+            1 => $langs->trans('MultipriceRules'),
260
+            2 => 'generator'
261
+        );
262
+        $h++;
263
+    }
264
+
265
+    // Show more tabs from modules
266
+    // Entries must be declared in modules descriptor with line
267 267
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
268 268
     // $this->tabs = array('entity:-tabname);   												to remove a tab
269
-	complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin');
269
+    complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin');
270 270
 
271 271
     $head[$h][0] = BASE_URI . '?controller=product/admin&method=product_extrafields';
272
-	$head[$h][1] = $langs->trans("ExtraFields");
273
-	$head[$h][2] = 'attributes';
274
-	$h++;
272
+    $head[$h][1] = $langs->trans("ExtraFields");
273
+    $head[$h][2] = 'attributes';
274
+    $h++;
275 275
 
276
-	complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin','remove');
276
+    complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin','remove');
277 277
 
278
-	return $head;
278
+    return $head;
279 279
 }
280 280
 
281 281
 
@@ -319,146 +319,146 @@  discard block
 block discarded – undo
319 319
  */
320 320
 function show_stats_for_company($product,$socid)
321 321
 {
322
-	global $conf,$langs,$user,$db;
323
-
324
-	$nblines = 0;
325
-
326
-	print '<tr class="liste_titre">';
327
-	print '<td align="left" width="25%">'.$langs->trans("Referers").'</td>';
328
-	print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
329
-	print '<td align="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>';
330
-	print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
331
-	print '</tr>';
332
-
333
-	// Customer proposals
334
-	if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
335
-	{
336
-		$nblines++;
337
-		$ret=$product->load_stats_propale($socid);
338
-		if ($ret < 0) dol_print_error($db);
339
-		$langs->load("propal");
340
-		print '<tr><td>';
341
-		print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
342
-		print '</td><td align="right">';
343
-		print $product->stats_propale['customers'];
344
-		print '</td><td align="right">';
345
-		print $product->stats_propale['nb'];
346
-		print '</td><td align="right">';
347
-		print $product->stats_propale['qty'];
348
-		print '</td>';
349
-		print '</tr>';
350
-	}
351
-	// Supplier proposals
352
-	if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
353
-	{
354
-		$nblines++;
355
-		$ret=$product->load_stats_proposal_supplier($socid);
356
-		if ($ret < 0) dol_print_error($db);
357
-		$langs->load("propal");
358
-		print '<tr><td>';
359
-		print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>';
360
-		print '</td><td align="right">';
361
-		print $product->stats_proposal_supplier['suppliers'];
362
-		print '</td><td align="right">';
363
-		print $product->stats_proposal_supplier['nb'];
364
-		print '</td><td align="right">';
365
-		print $product->stats_proposal_supplier['qty'];
366
-		print '</td>';
367
-		print '</tr>';
368
-	}
369
-	// Customer orders
370
-	if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
371
-	{
372
-		$nblines++;
373
-		$ret=$product->load_stats_commande($socid);
374
-		if ($ret < 0) dol_print_error($db);
375
-		$langs->load("orders");
376
-		print '<tr><td>';
377
-		print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
378
-		print '</td><td align="right">';
379
-		print $product->stats_commande['customers'];
380
-		print '</td><td align="right">';
381
-		print $product->stats_commande['nb'];
382
-		print '</td><td align="right">';
383
-		print $product->stats_commande['qty'];
384
-		print '</td>';
385
-		print '</tr>';
386
-	}
387
-	// Supplier orders
388
-	if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
389
-	{
390
-		$nblines++;
391
-		$ret=$product->load_stats_commande_fournisseur($socid);
392
-		if ($ret < 0) dol_print_error($db);
393
-		$langs->load("orders");
394
-		print '<tr><td>';
395
-		print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
396
-		print '</td><td align="right">';
397
-		print $product->stats_commande_fournisseur['suppliers'];
398
-		print '</td><td align="right">';
399
-		print $product->stats_commande_fournisseur['nb'];
400
-		print '</td><td align="right">';
401
-		print $product->stats_commande_fournisseur['qty'];
402
-		print '</td>';
403
-		print '</tr>';
404
-	}
405
-	// Customer invoices
406
-	if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
407
-	{
408
-		$nblines++;
409
-		$ret=$product->load_stats_facture($socid);
410
-		if ($ret < 0) dol_print_error($db);
411
-		$langs->load("bills");
412
-		print '<tr><td>';
413
-		print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
414
-		print '</td><td align="right">';
415
-		print $product->stats_facture['customers'];
416
-		print '</td><td align="right">';
417
-		print $product->stats_facture['nb'];
418
-		print '</td><td align="right">';
419
-		print $product->stats_facture['qty'];
420
-		print '</td>';
421
-		print '</tr>';
422
-	}
423
-	// Supplier invoices
424
-	if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
425
-	{
426
-		$nblines++;
427
-		$ret=$product->load_stats_facture_fournisseur($socid);
428
-		if ($ret < 0) dol_print_error($db);
429
-		$langs->load("bills");
430
-		print '<tr><td>';
431
-		print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
432
-		print '</td><td align="right">';
433
-		print $product->stats_facture_fournisseur['suppliers'];
434
-		print '</td><td align="right">';
435
-		print $product->stats_facture_fournisseur['nb'];
436
-		print '</td><td align="right">';
437
-		print $product->stats_facture_fournisseur['qty'];
438
-		print '</td>';
439
-		print '</tr>';
440
-	}
441
-
442
-	// Contracts
443
-	if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
444
-	{
445
-		$nblines++;
446
-		$ret=$product->load_stats_contrat($socid);
447
-		if ($ret < 0) dol_print_error($db);
448
-		$langs->load("contracts");
449
-		print '<tr><td>';
450
-		print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
451
-		print '</td><td align="right">';
452
-		print $product->stats_contrat['customers'];
453
-		print '</td><td align="right">';
454
-		print $product->stats_contrat['nb'];
455
-		print '</td><td align="right">';
456
-		print $product->stats_contrat['qty'];
457
-		print '</td>';
458
-		print '</tr>';
459
-	}
460
-
461
-	return $nblines++;
322
+    global $conf,$langs,$user,$db;
323
+
324
+    $nblines = 0;
325
+
326
+    print '<tr class="liste_titre">';
327
+    print '<td align="left" width="25%">'.$langs->trans("Referers").'</td>';
328
+    print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
329
+    print '<td align="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>';
330
+    print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
331
+    print '</tr>';
332
+
333
+    // Customer proposals
334
+    if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
335
+    {
336
+        $nblines++;
337
+        $ret=$product->load_stats_propale($socid);
338
+        if ($ret < 0) dol_print_error($db);
339
+        $langs->load("propal");
340
+        print '<tr><td>';
341
+        print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
342
+        print '</td><td align="right">';
343
+        print $product->stats_propale['customers'];
344
+        print '</td><td align="right">';
345
+        print $product->stats_propale['nb'];
346
+        print '</td><td align="right">';
347
+        print $product->stats_propale['qty'];
348
+        print '</td>';
349
+        print '</tr>';
350
+    }
351
+    // Supplier proposals
352
+    if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
353
+    {
354
+        $nblines++;
355
+        $ret=$product->load_stats_proposal_supplier($socid);
356
+        if ($ret < 0) dol_print_error($db);
357
+        $langs->load("propal");
358
+        print '<tr><td>';
359
+        print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>';
360
+        print '</td><td align="right">';
361
+        print $product->stats_proposal_supplier['suppliers'];
362
+        print '</td><td align="right">';
363
+        print $product->stats_proposal_supplier['nb'];
364
+        print '</td><td align="right">';
365
+        print $product->stats_proposal_supplier['qty'];
366
+        print '</td>';
367
+        print '</tr>';
368
+    }
369
+    // Customer orders
370
+    if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
371
+    {
372
+        $nblines++;
373
+        $ret=$product->load_stats_commande($socid);
374
+        if ($ret < 0) dol_print_error($db);
375
+        $langs->load("orders");
376
+        print '<tr><td>';
377
+        print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
378
+        print '</td><td align="right">';
379
+        print $product->stats_commande['customers'];
380
+        print '</td><td align="right">';
381
+        print $product->stats_commande['nb'];
382
+        print '</td><td align="right">';
383
+        print $product->stats_commande['qty'];
384
+        print '</td>';
385
+        print '</tr>';
386
+    }
387
+    // Supplier orders
388
+    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
389
+    {
390
+        $nblines++;
391
+        $ret=$product->load_stats_commande_fournisseur($socid);
392
+        if ($ret < 0) dol_print_error($db);
393
+        $langs->load("orders");
394
+        print '<tr><td>';
395
+        print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
396
+        print '</td><td align="right">';
397
+        print $product->stats_commande_fournisseur['suppliers'];
398
+        print '</td><td align="right">';
399
+        print $product->stats_commande_fournisseur['nb'];
400
+        print '</td><td align="right">';
401
+        print $product->stats_commande_fournisseur['qty'];
402
+        print '</td>';
403
+        print '</tr>';
404
+    }
405
+    // Customer invoices
406
+    if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
407
+    {
408
+        $nblines++;
409
+        $ret=$product->load_stats_facture($socid);
410
+        if ($ret < 0) dol_print_error($db);
411
+        $langs->load("bills");
412
+        print '<tr><td>';
413
+        print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
414
+        print '</td><td align="right">';
415
+        print $product->stats_facture['customers'];
416
+        print '</td><td align="right">';
417
+        print $product->stats_facture['nb'];
418
+        print '</td><td align="right">';
419
+        print $product->stats_facture['qty'];
420
+        print '</td>';
421
+        print '</tr>';
422
+    }
423
+    // Supplier invoices
424
+    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
425
+    {
426
+        $nblines++;
427
+        $ret=$product->load_stats_facture_fournisseur($socid);
428
+        if ($ret < 0) dol_print_error($db);
429
+        $langs->load("bills");
430
+        print '<tr><td>';
431
+        print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
432
+        print '</td><td align="right">';
433
+        print $product->stats_facture_fournisseur['suppliers'];
434
+        print '</td><td align="right">';
435
+        print $product->stats_facture_fournisseur['nb'];
436
+        print '</td><td align="right">';
437
+        print $product->stats_facture_fournisseur['qty'];
438
+        print '</td>';
439
+        print '</tr>';
440
+    }
441
+
442
+    // Contracts
443
+    if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
444
+    {
445
+        $nblines++;
446
+        $ret=$product->load_stats_contrat($socid);
447
+        if ($ret < 0) dol_print_error($db);
448
+        $langs->load("contracts");
449
+        print '<tr><td>';
450
+        print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
451
+        print '</td><td align="right">';
452
+        print $product->stats_contrat['customers'];
453
+        print '</td><td align="right">';
454
+        print $product->stats_contrat['nb'];
455
+        print '</td><td align="right">';
456
+        print $product->stats_contrat['qty'];
457
+        print '</td>';
458
+        print '</tr>';
459
+    }
460
+
461
+    return $nblines++;
462 462
 }
463 463
 
464 464
 
@@ -472,50 +472,50 @@  discard block
 block discarded – undo
472 472
  */
473 473
 function measuring_units_string($unit,$measuring_style='')
474 474
 {
475
-	global $langs;
476
-
477
-	$measuring_units=array();
478
-	if ($measuring_style == 'weight')
479
-	{
480
-		$measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton");
481
-		$measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg");
482
-		$measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg");
483
-		$measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg");
484
-		$measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
485
-		$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
486
-	}
487
-	else if ($measuring_style == 'size')
488
-	{
489
-		$measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm");
490
-		$measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm");
491
-		$measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm");
492
-		$measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm");
475
+    global $langs;
476
+
477
+    $measuring_units=array();
478
+    if ($measuring_style == 'weight')
479
+    {
480
+        $measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton");
481
+        $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg");
482
+        $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg");
483
+        $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg");
484
+        $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
485
+        $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
486
+    }
487
+    else if ($measuring_style == 'size')
488
+    {
489
+        $measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm");
490
+        $measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm");
491
+        $measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm");
492
+        $measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm");
493 493
         $measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot");
494
-		$measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch");
495
-	}
496
-	else if ($measuring_style == 'surface')
497
-	{
498
-		$measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2");
499
-		$measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2");
500
-		$measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2");
501
-		$measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2");
494
+        $measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch");
495
+    }
496
+    else if ($measuring_style == 'surface')
497
+    {
498
+        $measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2");
499
+        $measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2");
500
+        $measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2");
501
+        $measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2");
502 502
         $measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2");
503
-		$measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2");
504
-	}
505
-	else if ($measuring_style == 'volume')
506
-	{
507
-		$measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3");
508
-		$measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3");
509
-		$measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3");
510
-		$measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3");
503
+        $measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2");
504
+    }
505
+    else if ($measuring_style == 'volume')
506
+    {
507
+        $measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3");
508
+        $measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3");
509
+        $measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3");
510
+        $measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3");
511 511
         $measuring_units[88] = $langs->transnoentitiesnoconv("VolumeUnitfoot3");
512 512
         $measuring_units[89] = $langs->transnoentitiesnoconv("VolumeUnitinch3");
513
-		$measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce");
514
-		$measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre");
513
+        $measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce");
514
+        $measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre");
515 515
         $measuring_units[99] = $langs->transnoentitiesnoconv("VolumeUnitgallon");
516
-	}
516
+    }
517 517
 
518
-	return $measuring_units[$unit];
518
+    return $measuring_units[$unit];
519 519
 }
520 520
 
521 521
 /**
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
  */
528 528
 function measuring_units_squared($unit)
529 529
 {
530
-	$measuring_units=array();
531
-	$measuring_units[0] = 0;   // m -> m3
532
-	$measuring_units[-1] = -2; // dm-> dm2
533
-	$measuring_units[-2] = -4; // cm -> cm2
534
-	$measuring_units[-3] = -6; // mm -> mm2
535
-	$measuring_units[98] = 98; // foot -> foot2
536
-	$measuring_units[99] = 99; // inch -> inch2
537
-	return $measuring_units[$unit];
530
+    $measuring_units=array();
531
+    $measuring_units[0] = 0;   // m -> m3
532
+    $measuring_units[-1] = -2; // dm-> dm2
533
+    $measuring_units[-2] = -4; // cm -> cm2
534
+    $measuring_units[-3] = -6; // mm -> mm2
535
+    $measuring_units[98] = 98; // foot -> foot2
536
+    $measuring_units[99] = 99; // inch -> inch2
537
+    return $measuring_units[$unit];
538 538
 }
539 539
 
540 540
 
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
  */
548 548
 function measuring_units_cubed($unit)
549 549
 {
550
-	$measuring_units=array();
551
-	$measuring_units[0] = 0;   // m -> m2
552
-	$measuring_units[-1] = -3; // dm-> dm3
553
-	$measuring_units[-2] = -6; // cm -> cm3
554
-	$measuring_units[-3] = -9; // mm -> mm3
555
-	$measuring_units[98] = 88; // foot -> foot3
556
-	$measuring_units[99] = 89; // inch -> inch3
557
-	return $measuring_units[$unit];
550
+    $measuring_units=array();
551
+    $measuring_units[0] = 0;   // m -> m2
552
+    $measuring_units[-1] = -3; // dm-> dm3
553
+    $measuring_units[-2] = -6; // cm -> cm3
554
+    $measuring_units[-3] = -9; // mm -> mm3
555
+    $measuring_units[98] = 88; // foot -> foot3
556
+    $measuring_units[99] = 89; // inch -> inch3
557
+    return $measuring_units[$unit];
558 558
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modMargin.class.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -30,119 +30,119 @@
 block discarded – undo
30 30
  */
31 31
 class modMargin extends DolibarrModules
32 32
 {
33
-	/**
34
-	 * 	Constructor
35
-	 *
36
-	 * 	@param	DoliDB	$db		Database handler
37
-	 */
38
-	function __construct($db)
39
-	{
40
-		$this->db = $db;
41
-
42
-		// Id for module (must be unique).
43
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
44
-		$this->numero = 59000;
45
-		// Key text used to identify module (for permissions, menus, etc...)
46
-		$this->rights_class = 'margins';
47
-
48
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
49
-		// It is used to group modules in module setup page
50
-		$this->family = "financial";
51
-		$this->module_position = '55';
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
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
55
-		$this->description = "Margin management";
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		// Name of png file (without png) used for this module.
61
-		// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
62
-		$this->picto='margin';
63
-
64
-		// Data directories to create when module is enabled.
65
-		$this->dirs = array('/margin/temp');
66
-
67
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.
68
-		$this->config_page_url = array("margin.php@margin");
69
-
70
-		// Dependencies
71
-		$this->hidden = false;			// A condition to hide module
72
-		$this->depends = array("modPropale", "modProduct");		// List of module class names as string that must be enabled if this module is enabled
73
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
74
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
75
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
76
-		$this->need_dolibarr_version = array(3,2);	// Minimum version of Dolibarr required by module
77
-		$this->langfiles = array("margins");
78
-
79
-		// Constants
80
-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
81
-		// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
82
-		//                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
83
-		// );
84
-		$this->const = array(0=>array('MARGIN_TYPE','chaine','costprice','Rule for margin calculation by default',0,'current',0));			// List of particular constants to add when module is enabled
85
-
86
-		// New pages on tabs
87
-		$this->tabs = array(
33
+    /**
34
+     * 	Constructor
35
+     *
36
+     * 	@param	DoliDB	$db		Database handler
37
+     */
38
+    function __construct($db)
39
+    {
40
+        $this->db = $db;
41
+
42
+        // Id for module (must be unique).
43
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
44
+        $this->numero = 59000;
45
+        // Key text used to identify module (for permissions, menus, etc...)
46
+        $this->rights_class = 'margins';
47
+
48
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
49
+        // It is used to group modules in module setup page
50
+        $this->family = "financial";
51
+        $this->module_position = '55';
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
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
55
+        $this->description = "Margin management";
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        // Name of png file (without png) used for this module.
61
+        // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
62
+        $this->picto='margin';
63
+
64
+        // Data directories to create when module is enabled.
65
+        $this->dirs = array('/margin/temp');
66
+
67
+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.
68
+        $this->config_page_url = array("margin.php@margin");
69
+
70
+        // Dependencies
71
+        $this->hidden = false;			// A condition to hide module
72
+        $this->depends = array("modPropale", "modProduct");		// List of module class names as string that must be enabled if this module is enabled
73
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
74
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
75
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
76
+        $this->need_dolibarr_version = array(3,2);	// Minimum version of Dolibarr required by module
77
+        $this->langfiles = array("margins");
78
+
79
+        // Constants
80
+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
81
+        // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
82
+        //                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
83
+        // );
84
+        $this->const = array(0=>array('MARGIN_TYPE','chaine','costprice','Rule for margin calculation by default',0,'current',0));			// List of particular constants to add when module is enabled
85
+
86
+        // New pages on tabs
87
+        $this->tabs = array(
88 88
             'product:+margin:Margins:margins:$user->rights->margins->liretous:?controller=margin/tabs&method=productMargins&id=__ID__',
89 89
             'thirdparty:+margin:Margins:margins:empty($user->societe_id) && $user->rights->margins->liretous && ($object->client > 0):?controller=margin/tabs&method=thirdpartyMargins&socid=__ID__'
90
-		);
90
+        );
91 91
 
92 92
 
93
-		// Boxes
94
-		$this->boxes = array();			// List of boxes
95
-		$r=0;
93
+        // Boxes
94
+        $this->boxes = array();			// List of boxes
95
+        $r=0;
96 96
 
97
-		// Permissions
98
-		$this->rights = array();		// Permission array used by this module
99
-		$r=0;
97
+        // Permissions
98
+        $this->rights = array();		// Permission array used by this module
99
+        $r=0;
100 100
 
101
-		// Main menu entries
102
-		$this->menu = array();			// List of menus to add
103
-		$r = 0;
101
+        // Main menu entries
102
+        $this->menu = array();			// List of menus to add
103
+        $r = 0;
104 104
 
105
-		// left menu entry
106
-		$this->menu[$r]=array(
107
-				'fk_menu'=>'fk_mainmenu=billing',			// Put 0 if this is a top menu
108
-    			'type'=>'left',			// This is a Top menu entry
109
-    			'titre'=>'Margins',
110
-    			'mainmenu'=>'billing',
111
-    			'leftmenu'=>'margins',
105
+        // left menu entry
106
+        $this->menu[$r]=array(
107
+                'fk_menu'=>'fk_mainmenu=billing',			// Put 0 if this is a top menu
108
+                'type'=>'left',			// This is a Top menu entry
109
+                'titre'=>'Margins',
110
+                'mainmenu'=>'billing',
111
+                'leftmenu'=>'margins',
112 112
             'url' => '?controller=margin&method=index',
113
-    			'langs'=>'margins',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
114
-    			'position'=>100,
115
-    			'enabled'=>'$conf->margin->enabled',			// Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
116
-    			'perms'=>'$user->rights->margins->liretous',	// Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
117
-    			'target'=>'',
118
-    			'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
119
-		$r++;
120
-
121
-		// Permissions
122
-		$this->rights = array();
123
-		$r=0;
124
-
125
-		$r++;
126
-		$this->rights[$r][0] = 59001; // id de la permission
127
-		$this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission
128
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
129
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
130
-		$this->rights[$r][4] = 'liretous';
131
-
132
-		$r++;
133
-		$this->rights[$r][0] = 59002; // id de la permission
134
-		$this->rights[$r][1] = 'Définir les marges'; // libelle de la permission
135
-		$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
136
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
137
-		$this->rights[$r][4] = 'creer';
138
-
139
-		$r++;
140
-		$this->rights[$r][0] = 59003; // id de la permission
141
-		$this->rights[$r][1] = 'Read every user margin'; // libelle de la permission
142
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
143
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
144
-		$this->rights[$r][4] = 'read';
145
-		$this->rights[$r][5] = 'all';
146
-	}
113
+                'langs'=>'margins',	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
114
+                'position'=>100,
115
+                'enabled'=>'$conf->margin->enabled',			// Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
116
+                'perms'=>'$user->rights->margins->liretous',	// Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
117
+                'target'=>'',
118
+                'user'=>2);				// 0=Menu for internal users, 1=external users, 2=both
119
+        $r++;
120
+
121
+        // Permissions
122
+        $this->rights = array();
123
+        $r=0;
124
+
125
+        $r++;
126
+        $this->rights[$r][0] = 59001; // id de la permission
127
+        $this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission
128
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
129
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
130
+        $this->rights[$r][4] = 'liretous';
131
+
132
+        $r++;
133
+        $this->rights[$r][0] = 59002; // id de la permission
134
+        $this->rights[$r][1] = 'Définir les marges'; // libelle de la permission
135
+        $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
136
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
137
+        $this->rights[$r][4] = 'creer';
138
+
139
+        $r++;
140
+        $this->rights[$r][0] = 59003; // id de la permission
141
+        $this->rights[$r][1] = 'Read every user margin'; // libelle de la permission
142
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
143
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
144
+        $this->rights[$r][4] = 'read';
145
+        $this->rights[$r][5] = 'all';
146
+    }
147 147
 }
148 148
 
Please login to merge, or discard this patch.
dolibarr/htdocs/don/card.php 1 patch
Indentation   +455 added lines, -455 removed lines patch added patch discarded remove patch
@@ -78,117 +78,117 @@  discard block
 block discarded – undo
78 78
 
79 79
 if ($action == 'update')
80 80
 {
81
-	if (! empty($cancel))
82
-	{
81
+    if (! empty($cancel))
82
+    {
83 83
         header("Location: " . $_SERVER['PHP_SELF'] . "&id=" . $id);
84
-		exit;
85
-	}
84
+        exit;
85
+    }
86 86
 
87
-	$error=0;
87
+    $error=0;
88 88
 
89 89
     if (empty($donation_date))
90 90
     {
91
-	    setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
91
+        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
92 92
         $action = "create";
93 93
         $error++;
94 94
     }
95 95
 
96
-	if (empty($amount))
97
-	{
98
-		setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
99
-		$action = "create";
100
-		$error++;
101
-	}
96
+    if (empty($amount))
97
+    {
98
+        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
99
+        $action = "create";
100
+        $error++;
101
+    }
102 102
 
103
-	if (! $error)
104
-	{
105
-		$object->fetch($id);
106
-
107
-		$object->firstname   = GETPOST("firstname",'alpha');
108
-		$object->lastname    = GETPOST("lastname",'alpha');
109
-		$object->societe     = GETPOST("societe",'alpha');
110
-		$object->address     = GETPOST("address",'alpha');
111
-		$object->amount      = price2num(GETPOST("amount",'alpha'));
112
-		$object->town        = GETPOST("town",'alpha');
113
-		$object->zip         = GETPOST("zipcode",'alpha');
103
+    if (! $error)
104
+    {
105
+        $object->fetch($id);
106
+
107
+        $object->firstname   = GETPOST("firstname",'alpha');
108
+        $object->lastname    = GETPOST("lastname",'alpha');
109
+        $object->societe     = GETPOST("societe",'alpha');
110
+        $object->address     = GETPOST("address",'alpha');
111
+        $object->amount      = price2num(GETPOST("amount",'alpha'));
112
+        $object->town        = GETPOST("town",'alpha');
113
+        $object->zip         = GETPOST("zipcode",'alpha');
114 114
         $object->country_id  = GETPOST('country_id', 'int');
115 115
         $object->email       = GETPOST("email",'alpha');
116
-		$object->date        = $donation_date;
117
-		$object->public      = GETPOST("public",'alpha');
118
-		$object->fk_project  = GETPOST("fk_project",'alpha');
119
-		$object->note_private= GETPOST("note_private",'none');
120
-		$object->note_public = GETPOST("note_public",'none');
121
-		$object->modepaymentid = GETPOST('modepayment','int');
122
-
123
-		// Fill array 'array_options' with data from add form
116
+        $object->date        = $donation_date;
117
+        $object->public      = GETPOST("public",'alpha');
118
+        $object->fk_project  = GETPOST("fk_project",'alpha');
119
+        $object->note_private= GETPOST("note_private",'none');
120
+        $object->note_public = GETPOST("note_public",'none');
121
+        $object->modepaymentid = GETPOST('modepayment','int');
122
+
123
+        // Fill array 'array_options' with data from add form
124 124
         $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
125
-		if ($ret < 0) $error++;
125
+        if ($ret < 0) $error++;
126 126
 
127
-		if ($object->update($user) > 0)
128
-		{
127
+        if ($object->update($user) > 0)
128
+        {
129 129
             header("Location: " . $_SERVER['PHP_SELF'] . "&id=" . $object->id);
130
-			exit;
131
-		}
132
-	}
130
+            exit;
131
+        }
132
+    }
133 133
 }
134 134
 
135 135
 if ($action == 'add')
136 136
 {
137
-	if (! empty($cancel))
138
-	{
139
-		header("Location: index.php");
140
-		exit;
141
-	}
137
+    if (! empty($cancel))
138
+    {
139
+        header("Location: index.php");
140
+        exit;
141
+    }
142 142
 
143
-	$error=0;
143
+    $error=0;
144 144
 
145 145
     if (empty($donation_date))
146 146
     {
147
-	    setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
147
+        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
148 148
         $action = "create";
149 149
         $error++;
150 150
     }
151 151
 
152
-	if (empty($amount))
153
-	{
154
-		setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
155
-		$action = "create";
156
-		$error++;
157
-	}
152
+    if (empty($amount))
153
+    {
154
+        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
155
+        $action = "create";
156
+        $error++;
157
+    }
158 158
 
159
-	if (! $error)
160
-	{
161
-		$object->firstname   = GETPOST("firstname",'alpha');
162
-		$object->lastname    = GETPOST("lastname",'alpha');
163
-		$object->societe     = GETPOST("societe",'alpha');
164
-		$object->address     = GETPOST("address",'alpha');
165
-		$object->amount      = price2num(GETPOST("amount",'alpha'));
166
-		$object->zip         = GETPOST("zipcode",'alpha');
167
-		$object->town        = GETPOST("town",'alpha');
159
+    if (! $error)
160
+    {
161
+        $object->firstname   = GETPOST("firstname",'alpha');
162
+        $object->lastname    = GETPOST("lastname",'alpha');
163
+        $object->societe     = GETPOST("societe",'alpha');
164
+        $object->address     = GETPOST("address",'alpha');
165
+        $object->amount      = price2num(GETPOST("amount",'alpha'));
166
+        $object->zip         = GETPOST("zipcode",'alpha');
167
+        $object->town        = GETPOST("town",'alpha');
168 168
         $object->country_id  = GETPOST('country_id', 'int');
169 169
         $object->email       = GETPOST("email",'alpha');
170
-		$object->date        = $donation_date;
171
-		$object->note_private= GETPOST("note_private",'none');
172
-		$object->note_public = GETPOST("note_public",'none');
173
-		$object->public      = GETPOST("public",'alpha');
174
-		$object->fk_project  = GETPOST("fk_project",'alpha');
175
-		$object->modepaymentid = GETPOST('modepayment','int');
176
-
177
-		// Fill array 'array_options' with data from add form
170
+        $object->date        = $donation_date;
171
+        $object->note_private= GETPOST("note_private",'none');
172
+        $object->note_public = GETPOST("note_public",'none');
173
+        $object->public      = GETPOST("public",'alpha');
174
+        $object->fk_project  = GETPOST("fk_project",'alpha');
175
+        $object->modepaymentid = GETPOST('modepayment','int');
176
+
177
+        // Fill array 'array_options' with data from add form
178 178
         $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
179
-		if ($ret < 0) $error++;
179
+        if ($ret < 0) $error++;
180 180
 
181
-		$res = $object->create($user);
182
-		if ($res > 0)
183
-		{
181
+        $res = $object->create($user);
182
+        if ($res > 0)
183
+        {
184 184
             header("Location: " . $_SERVER['PHP_SELF'] . '&id=' . $res);
185
-			exit;
186
-		}
187
-		else
188
-		{
189
-			setEventMessages($object->error, $object->errors, 'errors');
190
-		}
191
-	}
185
+            exit;
186
+        }
187
+        else
188
+        {
189
+            setEventMessages($object->error, $object->errors, 'errors');
190
+        }
191
+    }
192 192
 }
193 193
 if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer)
194 194
 {
@@ -207,46 +207,46 @@  discard block
 block discarded – undo
207 207
 }
208 208
 if ($action == 'valid_promesse')
209 209
 {
210
-	$object->fetch($id);
211
-	if ($object->valid_promesse($id, $user->id) >= 0)
212
-	{
213
-		setEventMessages($langs->trans("DonationValidated", $object->ref), null);
210
+    $object->fetch($id);
211
+    if ($object->valid_promesse($id, $user->id) >= 0)
212
+    {
213
+        setEventMessages($langs->trans("DonationValidated", $object->ref), null);
214 214
 
215 215
         header("Location: " . $_SERVER['PHP_SELF'] . "&id=" . $id);
216
-		exit;
217
-	}
216
+        exit;
217
+    }
218 218
     else {
219
-	    setEventMessages($object->error, $object->errors, 'errors');
219
+        setEventMessages($object->error, $object->errors, 'errors');
220 220
     }
221 221
 }
222 222
 if ($action == 'set_cancel')
223 223
 {
224
-	$object->fetch($id);
225
-	if ($object->set_cancel($id) >= 0)
224
+    $object->fetch($id);
225
+    if ($object->set_cancel($id) >= 0)
226 226
     {
227 227
         header("Location: " . $_SERVER['PHP_SELF'] . "&id=" . $id);
228 228
         exit;
229 229
     }
230 230
     else {
231
-	    setEventMessages($object->error, $object->errors, 'errors');
231
+        setEventMessages($object->error, $object->errors, 'errors');
232 232
     }
233 233
 }
234 234
 if ($action == 'set_paid')
235 235
 {
236
-	$object->fetch($id);
237
-	if ($object->set_paid($id, $modepayment) >= 0)
238
-	{
236
+    $object->fetch($id);
237
+    if ($object->set_paid($id, $modepayment) >= 0)
238
+    {
239 239
         header("Location: " . $_SERVER['PHP_SELF'] . "&id=" . $id);
240
-		exit;
241
-	}
240
+        exit;
241
+    }
242 242
     else {
243
-	    setEventMessages($object->error, $object->errors, 'errors');
243
+        setEventMessages($object->error, $object->errors, 'errors');
244 244
     }
245 245
 }
246 246
 else if ($action == 'classin' && $user->rights->don->creer)
247 247
 {
248
-	$object->fetch($id);
249
-	$object->setProject($projectid);
248
+    $object->fetch($id);
249
+    $object->setProject($projectid);
250 250
 }
251 251
 
252 252
 // Actions to build doc
@@ -321,50 +321,50 @@  discard block
 block discarded – undo
321 321
 
322 322
 if ($action == 'create')
323 323
 {
324
-	print load_fiche_titre($langs->trans("AddDonation"));
324
+    print load_fiche_titre($langs->trans("AddDonation"));
325 325
 
326
-	print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
327
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
328
-	print '<input type="hidden" name="action" value="add">';
326
+    print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
327
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
328
+    print '<input type="hidden" name="action" value="add">';
329 329
 
330
-	dol_fiche_head('');
330
+    dol_fiche_head('');
331 331
 
332
-	print '<table class="border" width="100%">';
333
-	print '<tbody>';
332
+    print '<table class="border" width="100%">';
333
+    print '<tbody>';
334 334
 
335
-	// Ref
336
-	print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans('Draft') . '</td></tr>';
335
+    // Ref
336
+    print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans('Draft') . '</td></tr>';
337 337
 
338
-	// Company
339
-	if (! empty($conf->societe->enabled) && ! empty($conf->global->DONATION_USE_THIRDPARTIES))
340
-	{
341
-		// Thirdparty
342
-		print '<td>' . $langs->trans('Customer') . '</td>';
343
-		if ($soc->id > 0 && ! GETPOST('fac_rec','alpha'))
344
-		{
345
-			print '<td colspan="2">';
346
-			print $soc->getNomUrl(1);
347
-			print '<input type="hidden" name="socid" value="' . $soc->id . '">';
348
-			// Outstanding Bill
349
-			$outstandingBills = $soc->get_OutstandingBill();
350
-			print ' (' . $langs->trans('CurrentOutstandingBill') . ': ';
351
-			print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
352
-			if ($soc->outstanding_limit != '')
353
-			{
354
-				if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
355
-				print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
356
-			}
357
-			print ')';
358
-			print '</td>';
359
-		}
360
-		else
361
-		{
362
-			print '<td colspan="2">';
363
-			print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
364
-			// Option to reload page to retrieve customer informations. Note, this clear other input
365
-			if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
366
-			{
367
-				print '<script type="text/javascript">
338
+    // Company
339
+    if (! empty($conf->societe->enabled) && ! empty($conf->global->DONATION_USE_THIRDPARTIES))
340
+    {
341
+        // Thirdparty
342
+        print '<td>' . $langs->trans('Customer') . '</td>';
343
+        if ($soc->id > 0 && ! GETPOST('fac_rec','alpha'))
344
+        {
345
+            print '<td colspan="2">';
346
+            print $soc->getNomUrl(1);
347
+            print '<input type="hidden" name="socid" value="' . $soc->id . '">';
348
+            // Outstanding Bill
349
+            $outstandingBills = $soc->get_OutstandingBill();
350
+            print ' (' . $langs->trans('CurrentOutstandingBill') . ': ';
351
+            print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
352
+            if ($soc->outstanding_limit != '')
353
+            {
354
+                if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
355
+                print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
356
+            }
357
+            print ')';
358
+            print '</td>';
359
+        }
360
+        else
361
+        {
362
+            print '<td colspan="2">';
363
+            print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
364
+            // Option to reload page to retrieve customer informations. Note, this clear other input
365
+            if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
366
+            {
367
+                print '<script type="text/javascript">
368 368
 				$(document).ready(function() {
369 369
 					$("#socid").change(function() {
370 370
 						var socid = $(this).val();
@@ -374,82 +374,82 @@  discard block
 block discarded – undo
374 374
 					});
375 375
 				});
376 376
 				</script>';
377
-			}
377
+            }
378 378
             //print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'">'.$langs->trans("AddThirdParty").'</a>';
379 379
             print ' <a href="' . BASE_URI . '?controller=societe&method=card&action=create&client=3&fournisseur=0&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '">' . $langs->trans("AddThirdParty") . '</a>';
380
-			print '</td>';
381
-		}
382
-		print '</tr>' . "\n";
383
-	}
380
+            print '</td>';
381
+        }
382
+        print '</tr>' . "\n";
383
+    }
384 384
 
385
-	// Date
386
-	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Date").'</td><td>';
387
-	print $form->selectDate($donation_date?$donation_date:-1, '', '', '', '', "add", 1, 1);
388
-	print '</td>';
385
+    // Date
386
+    print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Date").'</td><td>';
387
+    print $form->selectDate($donation_date?$donation_date:-1, '', '', '', '', "add", 1, 1);
388
+    print '</td>';
389 389
 
390
-	// Amount
391
-	print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" value="'.dol_escape_htmltag(GETPOST("amount")).'" size="10"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
390
+    // Amount
391
+    print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" value="'.dol_escape_htmltag(GETPOST("amount")).'" size="10"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
392 392
 
393
-	// Public donation
394
-	print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
395
-	print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1);
396
-	print "</td></tr>\n";
393
+    // Public donation
394
+    print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
395
+    print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1);
396
+    print "</td></tr>\n";
397 397
 
398
-	if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES))
399
-	{
400
-		print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.dol_escape_htmltag(GETPOST("societe")).'" class="maxwidth200"></td></tr>';
401
-		print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.dol_escape_htmltag(GETPOST("lastname")).'" class="maxwidth200"></td></tr>';
402
-		print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST("firstname")).'" class="maxwidth200"></td></tr>';
403
-		print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
404
-		print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="3">'.dol_escape_htmltag(GETPOST("address")).'</textarea></td></tr>';
405
-
406
-		// Zip / Town
407
-		print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
408
-		print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
409
-		print ' ';
410
-		print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
411
-		print '</tr>';
412
-
413
-		// Country
414
-		print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
415
-		print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id);
416
-		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
417
-		print '</td></tr>';
418
-
419
-		print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>';
420
-	}
398
+    if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES))
399
+    {
400
+        print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.dol_escape_htmltag(GETPOST("societe")).'" class="maxwidth200"></td></tr>';
401
+        print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.dol_escape_htmltag(GETPOST("lastname")).'" class="maxwidth200"></td></tr>';
402
+        print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST("firstname")).'" class="maxwidth200"></td></tr>';
403
+        print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
404
+        print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="3">'.dol_escape_htmltag(GETPOST("address")).'</textarea></td></tr>';
405
+
406
+        // Zip / Town
407
+        print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
408
+        print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
409
+        print ' ';
410
+        print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
411
+        print '</tr>';
412
+
413
+        // Country
414
+        print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
415
+        print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id);
416
+        if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
417
+        print '</td></tr>';
418
+
419
+        print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>';
420
+    }
421 421
 
422
-	// Payment mode
423
-	print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
424
-	$selected = GETPOST('modepayment','int');
425
-	$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
426
-	print "</td></tr>\n";
422
+    // Payment mode
423
+    print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
424
+    $selected = GETPOST('modepayment','int');
425
+    $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
426
+    print "</td></tr>\n";
427 427
 
428
-	// Public note
429
-	print '<tr>';
430
-	print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>';
431
-	print '<td>';
428
+    // Public note
429
+    print '<tr>';
430
+    print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>';
431
+    print '<td>';
432 432
 
433 433
     $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
434
-	print $doleditor->Create(1);
435
-	print '</td></tr>';
436
-
437
-	// Private note
438
-	if (empty($user->societe_id)) {
439
-		print '<tr>';
440
-		print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
441
-		print '<td>';
442
-
443
-		$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
444
-		print $doleditor->Create(1);
445
-		print '</td></tr>';
446
-	}
434
+    print $doleditor->Create(1);
435
+    print '</td></tr>';
436
+
437
+    // Private note
438
+    if (empty($user->societe_id)) {
439
+        print '<tr>';
440
+        print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
441
+        print '<td>';
442
+
443
+        $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
444
+        print $doleditor->Create(1);
445
+        print '</td></tr>';
446
+    }
447 447
 
448
-	if (! empty($conf->projet->enabled))
448
+    if (! empty($conf->projet->enabled))
449 449
     {
450 450
         print "<tr><td>".$langs->trans("Project")."</td><td>";
451 451
         $formproject->select_projects(-1, $projectid,'fk_project', 0, 0, 1, 1);
452
-		print "</td></tr>\n";
452
+        print "</td></tr>\n";
453 453
     }
454 454
 
455 455
     // Other attributes
@@ -458,21 +458,21 @@  discard block
 block discarded – undo
458 458
     print $hookmanager->resPrint;
459 459
     if (empty($reshook))
460 460
     {
461
-		print $object->showOptionals($extrafields,'edit',$parameters);
461
+        print $object->showOptionals($extrafields,'edit',$parameters);
462 462
     }
463 463
 
464 464
     print '</tbody>';
465
-	print "</table>\n";
465
+    print "</table>\n";
466 466
 
467
-	dol_fiche_end();
467
+    dol_fiche_end();
468 468
 
469
-	print '<div class="center">';
470
-	print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
471
-	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
472
-	print '<input type="button" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" onClick="javascript:history.go(-1)">';
473
-	print '</div>';
469
+    print '<div class="center">';
470
+    print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
471
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
472
+    print '<input type="button" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" onClick="javascript:history.go(-1)">';
473
+    print '</div>';
474 474
 
475
-	print "</form>\n";
475
+    print "</form>\n";
476 476
 }
477 477
 
478 478
 
@@ -484,80 +484,80 @@  discard block
 block discarded – undo
484 484
 
485 485
 if (! empty($id) && $action == 'edit')
486 486
 {
487
-	$result=$object->fetch($id);
488
-	if ($result < 0) {
489
-		dol_print_error($db,$object->error); exit;
490
-	}
491
-	$result=$object->fetch_optionals();
492
-	if ($result < 0) {
493
-		dol_print_error($db); exit;
494
-	}
487
+    $result=$object->fetch($id);
488
+    if ($result < 0) {
489
+        dol_print_error($db,$object->error); exit;
490
+    }
491
+    $result=$object->fetch_optionals();
492
+    if ($result < 0) {
493
+        dol_print_error($db); exit;
494
+    }
495 495
 
496
-	$hselected='card';
497
-	$head = donation_prepare_head($object);
496
+    $hselected='card';
497
+    $head = donation_prepare_head($object);
498 498
 
499
-	print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
500
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
501
-	print '<input type="hidden" name="action" value="update">';
502
-	print '<input type="hidden" name="rowid" value="'.$object->id.'">';
503
-	print '<input type="hidden" name="amount" value="'.$object->amount.'">';
499
+    print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
500
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
501
+    print '<input type="hidden" name="action" value="update">';
502
+    print '<input type="hidden" name="rowid" value="'.$object->id.'">';
503
+    print '<input type="hidden" name="amount" value="'.$object->amount.'">';
504 504
 
505 505
 
506
-	dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
506
+    dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
507 507
 
508
-	print '<table class="border" width="100%">';
508
+    print '<table class="border" width="100%">';
509 509
 
510
-	// Ref
511
-	print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2">';
512
-	print $object->getNomUrl();
513
-	print '</td>';
514
-	print '</tr>';
510
+    // Ref
511
+    print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2">';
512
+    print $object->getNomUrl();
513
+    print '</td>';
514
+    print '</tr>';
515 515
 
516
-	// Date
517
-	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Date").'</td><td>';
518
-	print $form->selectDate($object->date,'','','','',"update");
519
-	print '</td>';
516
+    // Date
517
+    print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Date").'</td><td>';
518
+    print $form->selectDate($object->date,'','','','',"update");
519
+    print '</td>';
520 520
 
521
-	// Amount
522
-	if ($object->statut == 0)
523
-	{
524
-		print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.dol_escape_htmltag($object->amount).'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
525
-	}
526
-	else
527
-	{
528
-		print '<tr><td>'.$langs->trans("Amount").'</td><td>';
529
-		print price($object->amount,0,$langs,0,0,-1,$conf->currency);
530
-		print '</td></tr>';
531
-	}
521
+    // Amount
522
+    if ($object->statut == 0)
523
+    {
524
+        print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.dol_escape_htmltag($object->amount).'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
525
+    }
526
+    else
527
+    {
528
+        print '<tr><td>'.$langs->trans("Amount").'</td><td>';
529
+        print price($object->amount,0,$langs,0,0,-1,$conf->currency);
530
+        print '</td></tr>';
531
+    }
532 532
 
533
-	print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
534
-	print $form->selectyesno("public",1,1);
535
-	print "</td>";
536
-	print "</tr>\n";
533
+    print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
534
+    print $form->selectyesno("public",1,1);
535
+    print "</td>";
536
+    print "</tr>\n";
537 537
 
538
-	$langs->load("companies");
539
-	print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="maxwidth200" value="'.dol_escape_htmltag($object->societe).'"></td></tr>';
540
-	print '<tr><td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="maxwidth200" value="'.dol_escape_htmltag($object->lastname).'"></td></tr>';
541
-	print '<tr><td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="maxwidth200" value="'.dol_escape_htmltag($object->firstname).'"></td></tr>';
542
-	print '<tr><td>'.$langs->trans("Address").'</td><td>';
543
-	print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag($object->address).'</textarea></td></tr>';
538
+    $langs->load("companies");
539
+    print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="maxwidth200" value="'.dol_escape_htmltag($object->societe).'"></td></tr>';
540
+    print '<tr><td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="maxwidth200" value="'.dol_escape_htmltag($object->lastname).'"></td></tr>';
541
+    print '<tr><td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="maxwidth200" value="'.dol_escape_htmltag($object->firstname).'"></td></tr>';
542
+    print '<tr><td>'.$langs->trans("Address").'</td><td>';
543
+    print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag($object->address).'</textarea></td></tr>';
544 544
 
545 545
     // Zip / Town
546 546
     print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
547
-	print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
547
+    print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
548 548
     print ' ';
549
-	print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
550
-	print '</tr>';
549
+    print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
550
+    print '</tr>';
551 551
 
552
-	// Country
553
-	print '<tr><td class="titlefieldcreate">'.$langs->trans('Country').'</td><td>';
554
-	print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id');
555
-	if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
556
-	print '</td></tr>';
552
+    // Country
553
+    print '<tr><td class="titlefieldcreate">'.$langs->trans('Country').'</td><td>';
554
+    print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id');
555
+    if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
556
+    print '</td></tr>';
557 557
 
558
-	print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" class="maxwidth200" value="'.dol_escape_htmltag($object->email).'"></td></tr>';
558
+    print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" class="maxwidth200" value="'.dol_escape_htmltag($object->email).'"></td></tr>';
559 559
 
560
-	// Payment mode
560
+    // Payment mode
561 561
     print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
562 562
     if ($object->modepaymentid) $selected = $object->modepaymentid;
563 563
     else $selected = '';
@@ -565,16 +565,16 @@  discard block
 block discarded – undo
565 565
     print "</td></tr>\n";
566 566
 
567 567
     // Status
568
-	print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
568
+    print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
569 569
 
570 570
     // Project
571 571
     if (! empty($conf->projet->enabled))
572 572
     {
573
-    	$formproject=new FormProjets($db);
573
+        $formproject=new FormProjets($db);
574 574
 
575 575
         $langs->load('projects');
576 576
         print '<tr><td>'.$langs->trans('Project').'</td><td>';
577
-		$formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 0, 1, 1);
577
+        $formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 0, 1, 1);
578 578
         print '</td></tr>';
579 579
     }
580 580
 
@@ -584,16 +584,16 @@  discard block
 block discarded – undo
584 584
     print $hookmanager->resPrint;
585 585
     if (empty($reshook))
586 586
     {
587
-      	print $object->showOptionals($extrafields,'edit');
587
+            print $object->showOptionals($extrafields,'edit');
588 588
     }
589 589
 
590
-	print "</table>\n";
590
+    print "</table>\n";
591 591
 
592
-	dol_fiche_end();
592
+    dol_fiche_end();
593 593
 
594
-	print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>';
594
+    print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>';
595 595
 
596
-	print "</form>\n";
596
+    print "</form>\n";
597 597
 }
598 598
 
599 599
 
@@ -605,66 +605,66 @@  discard block
 block discarded – undo
605 605
 /* ************************************************************ */
606 606
 if (! empty($id) && $action != 'edit')
607 607
 {
608
-	// Confirmation delete
608
+    // Confirmation delete
609 609
     if ($action == 'delete')
610 610
     {
611 611
         $text=$langs->trans("ConfirmDeleteADonation");
612 612
         print $form->formconfirm($_SERVER["PHP_SELF"] . "&id=" . $object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1);
613 613
     }
614 614
 
615
-	$result=$object->fetch($id);
616
-	if ($result < 0) {
617
-		dol_print_error($db,$object->error); exit;
618
-	}
619
-	$result=$object->fetch_optionals();
620
-	if ($result < 0) {
621
-		dol_print_error($db); exit;
622
-	}
615
+    $result=$object->fetch($id);
616
+    if ($result < 0) {
617
+        dol_print_error($db,$object->error); exit;
618
+    }
619
+    $result=$object->fetch_optionals();
620
+    if ($result < 0) {
621
+        dol_print_error($db); exit;
622
+    }
623 623
 
624
-	$hselected='card';
624
+    $hselected='card';
625 625
 
626
-	$head = donation_prepare_head($object);
627
-	dol_fiche_head($head, $hselected, $langs->trans("Donation"), -1, 'generic');
626
+    $head = donation_prepare_head($object);
627
+    dol_fiche_head($head, $hselected, $langs->trans("Donation"), -1, 'generic');
628 628
 
629
-	// Print form confirm
630
-	print $formconfirm;
629
+    // Print form confirm
630
+    print $formconfirm;
631 631
 
632 632
     // $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
633 633
     $linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
634 634
 
635
-	$morehtmlref='<div class="refidno">';
636
-	// Project
637
-	if (! empty($conf->projet->enabled))
638
-	{
639
-	    $langs->load("projects");
640
-	    $morehtmlref.=$langs->trans('Project') . ' ';
641
-	    if ($user->rights->don->creer)
642
-	    {
643
-	        if ($action != 'classify')
644
-	            $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
645
-	            if ($action == 'classify') {
635
+    $morehtmlref='<div class="refidno">';
636
+    // Project
637
+    if (! empty($conf->projet->enabled))
638
+    {
639
+        $langs->load("projects");
640
+        $morehtmlref.=$langs->trans('Project') . ' ';
641
+        if ($user->rights->don->creer)
642
+        {
643
+            if ($action != 'classify')
644
+                $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
645
+                if ($action == 'classify') {
646 646
                     $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">';
647
-	                $morehtmlref.='<input type="hidden" name="action" value="classin">';
648
-	                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
649
-	                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
650
-	                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
651
-	                $morehtmlref.='</form>';
652
-	            } else {
647
+                    $morehtmlref.='<input type="hidden" name="action" value="classin">';
648
+                    $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
649
+                    $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
650
+                    $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
651
+                    $morehtmlref.='</form>';
652
+                } else {
653 653
                     $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '&id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
654
-	            }
655
-	    } else {
656
-	        if (! empty($object->fk_project)) {
657
-	            $proj = new Project($db);
658
-	            $proj->fetch($object->fk_project);
654
+                }
655
+        } else {
656
+            if (! empty($object->fk_project)) {
657
+                $proj = new Project($db);
658
+                $proj->fetch($object->fk_project);
659 659
                 $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&methos=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
660
-	            $morehtmlref.=$proj->ref;
661
-	            $morehtmlref.='</a>';
662
-	        } else {
663
-	            $morehtmlref.='';
664
-	        }
665
-	    }
666
-	}
667
-	$morehtmlref.='</div>';
660
+                $morehtmlref.=$proj->ref;
661
+                $morehtmlref.='</a>';
662
+            } else {
663
+                $morehtmlref.='';
664
+            }
665
+        }
666
+    }
667
+    $morehtmlref.='</div>';
668 668
 
669 669
 
670 670
     dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
@@ -676,195 +676,195 @@  discard block
 block discarded – undo
676 676
 
677 677
     print '<table class="border" width="100%">';
678 678
 
679
-	// Date
680
-	print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td colspan="2">';
681
-	print dol_print_date($object->date,"day");
682
-	print "</td>";
679
+    // Date
680
+    print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td colspan="2">';
681
+    print dol_print_date($object->date,"day");
682
+    print "</td>";
683 683
 
684 684
     print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">';
685
-	print price($object->amount,0,$langs,0,0,-1,$conf->currency);
686
-	print '</td></tr>';
685
+    print price($object->amount,0,$langs,0,0,-1,$conf->currency);
686
+    print '</td></tr>';
687 687
 
688
-	print '<tr><td>'.$langs->trans("PublicDonation").'</td><td colspan="2">';
689
-	print yn($object->public);
690
-	print '</td></tr>';
688
+    print '<tr><td>'.$langs->trans("PublicDonation").'</td><td colspan="2">';
689
+    print yn($object->public);
690
+    print '</td></tr>';
691 691
 
692
-	print '<tr><td>'.$langs->trans("Company").'</td><td colspan="2">'.$object->societe.'</td></tr>';
693
-	print '<tr><td>'.$langs->trans("Lastname").'</td><td colspan="2">'.$object->lastname.'</td></tr>';
694
-	print '<tr><td>'.$langs->trans("Firstname").'</td><td colspan="2">'.$object->firstname.'</td></tr>';
692
+    print '<tr><td>'.$langs->trans("Company").'</td><td colspan="2">'.$object->societe.'</td></tr>';
693
+    print '<tr><td>'.$langs->trans("Lastname").'</td><td colspan="2">'.$object->lastname.'</td></tr>';
694
+    print '<tr><td>'.$langs->trans("Firstname").'</td><td colspan="2">'.$object->firstname.'</td></tr>';
695 695
 
696
-	// Payment mode
697
-	print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
698
-	$form->form_modes_reglement(null, $object->modepaymentid,'none');
699
-	print "</td></tr>\n";
696
+    // Payment mode
697
+    print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
698
+    $form->form_modes_reglement(null, $object->modepaymentid,'none');
699
+    print "</td></tr>\n";
700 700
 
701
-	// Other attributes
702
-	$cols = 2;
703
-	include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
701
+    // Other attributes
702
+    $cols = 2;
703
+    include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
704 704
 
705
-	print '</table>';
705
+    print '</table>';
706 706
 
707
-	print '</div>';
708
-	print '<div class="fichehalfright">';
709
-	print '<div class="ficheaddleft">';
707
+    print '</div>';
708
+    print '<div class="fichehalfright">';
709
+    print '<div class="ficheaddleft">';
710 710
 
711
-	/*
711
+    /*
712 712
 	 * Payments
713 713
 	 */
714
-	$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
715
-	$sql.= "c.code as type_code,c.libelle as paiement_type";
716
-	$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
717
-	$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
718
-	$sql.= ", ".MAIN_DB_PREFIX."don as d";
719
-	$sql.= " WHERE d.rowid = '".$id."'";
720
-	$sql.= " AND p.fk_donation = d.rowid";
721
-	$sql.= " AND d.entity IN (".getEntity('donation').")";
722
-	$sql.= " AND p.fk_typepayment = c.id";
723
-	$sql.= " ORDER BY dp";
724
-
725
-	//print $sql;
726
-	$resql = $db->query($sql);
727
-	if ($resql)
728
-	{
729
-		$num = $db->num_rows($resql);
730
-		$i = 0; $total = 0;
731
-		print '<table class="noborder" width="100%">';
732
-		print '<tr class="liste_titre">';
733
-		print '<td>'.$langs->trans("RefPayment").'</td>';
734
-		print '<td>'.$langs->trans("Date").'</td>';
735
-		print '<td>'.$langs->trans("Type").'</td>';
736
-   		print '<td align="right">'.$langs->trans("Amount").'</td>';
737
-   		print '</tr>';
738
-
739
-		while ($i < $num)
740
-		{
741
-			$objp = $db->fetch_object($resql);
742
-
743
-			print '<tr class="oddeven"><td>';
714
+    $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
715
+    $sql.= "c.code as type_code,c.libelle as paiement_type";
716
+    $sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
717
+    $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
718
+    $sql.= ", ".MAIN_DB_PREFIX."don as d";
719
+    $sql.= " WHERE d.rowid = '".$id."'";
720
+    $sql.= " AND p.fk_donation = d.rowid";
721
+    $sql.= " AND d.entity IN (".getEntity('donation').")";
722
+    $sql.= " AND p.fk_typepayment = c.id";
723
+    $sql.= " ORDER BY dp";
724
+
725
+    //print $sql;
726
+    $resql = $db->query($sql);
727
+    if ($resql)
728
+    {
729
+        $num = $db->num_rows($resql);
730
+        $i = 0; $total = 0;
731
+        print '<table class="noborder" width="100%">';
732
+        print '<tr class="liste_titre">';
733
+        print '<td>'.$langs->trans("RefPayment").'</td>';
734
+        print '<td>'.$langs->trans("Date").'</td>';
735
+        print '<td>'.$langs->trans("Type").'</td>';
736
+            print '<td align="right">'.$langs->trans("Amount").'</td>';
737
+            print '</tr>';
738
+
739
+        while ($i < $num)
740
+        {
741
+            $objp = $db->fetch_object($resql);
742
+
743
+            print '<tr class="oddeven"><td>';
744 744
             print '<a href="' . BASE_URI . '?controller=don/payment&method=card&id=' . $objp->rowid . '">' . img_object($langs->trans("Payment"), "payment") . ' ' . $objp->rowid . '</a></td>';
745
-			print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
746
-		    $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
745
+            print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
746
+            $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
747 747
             print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
748
-			print '<td align="right">'.price($objp->amount)."</td>\n";
749
-			print "</tr>";
750
-			$totalpaid += $objp->amount;
751
-			$i++;
752
-		}
753
-
754
-		if ($object->paid == 0)
755
-		{
756
-			print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaid)."</td></tr>\n";
757
-			print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
758
-
759
-			$remaintopay = $object->amount - $totalpaid;
760
-
761
-			print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
762
-			print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':'').'><b>'.price($remaintopay)."</b></td></tr>\n";
763
-		}
764
-		print "</table>";
765
-		$db->free($resql);
766
-	}
767
-	else
768
-	{
769
-		dol_print_error($db);
770
-	}
748
+            print '<td align="right">'.price($objp->amount)."</td>\n";
749
+            print "</tr>";
750
+            $totalpaid += $objp->amount;
751
+            $i++;
752
+        }
753
+
754
+        if ($object->paid == 0)
755
+        {
756
+            print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaid)."</td></tr>\n";
757
+            print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
758
+
759
+            $remaintopay = $object->amount - $totalpaid;
760
+
761
+            print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
762
+            print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':'').'><b>'.price($remaintopay)."</b></td></tr>\n";
763
+        }
764
+        print "</table>";
765
+        $db->free($resql);
766
+    }
767
+    else
768
+    {
769
+        dol_print_error($db);
770
+    }
771 771
 
772
-	print '</div>';
773
-	print '</div>';
774
-	print '</div>';
772
+    print '</div>';
773
+    print '</div>';
774
+    print '</div>';
775 775
 
776
-	print '<div class="clearboth"></div>';
776
+    print '<div class="clearboth"></div>';
777 777
 
778 778
     dol_fiche_end();
779 779
 
780
-	$remaintopay = $object->amount - $totalpaid;
780
+    $remaintopay = $object->amount - $totalpaid;
781 781
 
782
-	// Actions buttons
782
+    // Actions buttons
783 783
 
784
-	print '<div class="tabsAction">';
784
+    print '<div class="tabsAction">';
785 785
 
786 786
     print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '&action=edit&rowid=' . $object->id . '">' . $langs->trans('Modify') . '</a></div>';
787 787
 
788
-	if ($object->statut == 0)
789
-	{
788
+    if ($object->statut == 0)
789
+    {
790 790
         print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '&rowid=' . $object->id . '&action=valid_promesse">' . $langs->trans("ValidPromess") . '</a></div>';
791
-	}
791
+    }
792 792
 
793 793
     if (($object->statut == 0 || $object->statut == 1) && $totalpaid == 0 && $object->paid == 0)
794 794
     {
795 795
         print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '&rowid=' . $object->id . '&action=set_cancel">' . $langs->trans("ClassifyCanceled") . "</a></div>";
796 796
     }
797 797
 
798
-	// Create payment
799
-	if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer)
800
-	{
801
-		if ($remaintopay == 0)
802
-		{
803
-			print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseRemainderToPayIsZero") . '">' . $langs->trans('DoPayment') . '</span></div>';
804
-		}
805
-		else
806
-		{
798
+    // Create payment
799
+    if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer)
800
+    {
801
+        if ($remaintopay == 0)
802
+        {
803
+            print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseRemainderToPayIsZero") . '">' . $langs->trans('DoPayment') . '</span></div>';
804
+        }
805
+        else
806
+        {
807 807
             print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=don/payment&method=payment&rowid=' . $object->id . '&amp;action=create">' . $langs->trans('DoPayment') . '</a></div>';
808
-		}
809
-	}
808
+        }
809
+    }
810 810
 
811
-	// Classify 'paid'
812
-	if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
813
-	{
814
-		print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
815
-	}
811
+    // Classify 'paid'
812
+    if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
813
+    {
814
+        print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
815
+    }
816 816
 
817
-	// Delete
818
-	if ($user->rights->don->supprimer)
819
-	{
820
-		if ($object->statut == -1 || $object->statut == 0)
821
-		{
817
+    // Delete
818
+    if ($user->rights->don->supprimer)
819
+    {
820
+        if ($object->statut == -1 || $object->statut == 0)
821
+        {
822 822
             // TODO: Original href="card.php?rowid='.$object->id.'&action=delete"
823 823
             print '<div class="inline-block divButAction"><a class="butActionDelete" href="?controller=don&method=card&rowid=' . $object->id . '&action=delete">' . $langs->trans("Delete") . "</a></div>";
824
-		}
825
-		else
826
-		{
827
-			print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
828
-		}
829
-	}
830
-	else
831
-	{
832
-		print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
833
-	}
824
+        }
825
+        else
826
+        {
827
+            print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
828
+        }
829
+    }
830
+    else
831
+    {
832
+        print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
833
+    }
834 834
 
835
-	print "</div>";
835
+    print "</div>";
836 836
 
837 837
 
838 838
     print '<div class="fichecenter"><div class="fichehalfleft">';
839 839
 
840
-	/*
840
+    /*
841 841
 	 * Documents generes
842 842
 	 */
843
-	$filename	=	dol_sanitizeFileName($object->id);
844
-	$filedir	=	$conf->don->dir_output . "/" . dol_sanitizeFileName($object->id);
843
+    $filename	=	dol_sanitizeFileName($object->id);
844
+    $filedir	=	$conf->don->dir_output . "/" . dol_sanitizeFileName($object->id);
845 845
     $urlsource = $_SERVER['PHP_SELF'] . '&rowid=' . $object->id;
846
-	$genallowed	=	(($object->paid == 0 || $user->admin) && $user->rights->don->lire);
847
-	$delallowed	=	$user->rights->don->creer;
846
+    $genallowed	=	(($object->paid == 0 || $user->admin) && $user->rights->don->lire);
847
+    $delallowed	=	$user->rights->don->creer;
848 848
 
849
-	print $formfile->showdocuments('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
849
+    print $formfile->showdocuments('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
850 850
 
851
-	// Show links to link elements
852
-	$linktoelem = $form->showLinkToObjectBlock($object, null, array('don'));
853
-	$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
851
+    // Show links to link elements
852
+    $linktoelem = $form->showLinkToObjectBlock($object, null, array('don'));
853
+    $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
854 854
 
855
-		// Show online payment link
856
-		$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
855
+        // Show online payment link
856
+        $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
857 857
 
858
-		if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT &&
859
-		{
860
-			print '<br><!-- Link to pay -->'."\n";
861
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
862
-			print showOnlinePaymentUrl('donation', $object->ref).'<br>';
863
-		}
858
+        if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT &&
859
+        {
860
+            print '<br><!-- Link to pay -->'."\n";
861
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
862
+            print showOnlinePaymentUrl('donation', $object->ref).'<br>';
863
+        }
864 864
 
865
-	print '</div><div class="fichehalfright"><div class="ficheaddleft">';
865
+    print '</div><div class="fichehalfright"><div class="ficheaddleft">';
866 866
 
867
-	print '</div></div></div>';
867
+    print '</div></div></div>';
868 868
 }
869 869
 
870 870
 llxFooter();
Please login to merge, or discard this patch.
dolibarr/htdocs/don/note.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 
64 64
 if ($action == 'classin' && $user->rights->don->creer)
65 65
 {
66
-	$object->fetch($id);
67
-	$object->setProject($projectid);
66
+    $object->fetch($id);
67
+    $object->setProject($projectid);
68 68
 }
69 69
 
70 70
 /*
@@ -80,59 +80,59 @@  discard block
 block discarded – undo
80 80
 
81 81
 if ($id > 0 || ! empty($ref))
82 82
 {
83
-	$object = new Don($db);
84
-	$object->fetch($id,$ref);
83
+    $object = new Don($db);
84
+    $object->fetch($id,$ref);
85 85
 
86
-	$head = donation_prepare_head($object);
86
+    $head = donation_prepare_head($object);
87 87
 
88
-	dol_fiche_head($head, 'note', $langs->trans("Donation"), -1, 'generic');
88
+    dol_fiche_head($head, 'note', $langs->trans("Donation"), -1, 'generic');
89 89
 
90 90
     // $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
91 91
     $linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
92 92
 
93
-	$morehtmlref='<div class="refidno">';
94
-	// Project
95
-	if (! empty($conf->projet->enabled))
96
-	{
97
-	    $langs->load("projects");
98
-	    $morehtmlref.=$langs->trans('Project') . ' ';
99
-	    if ($user->rights->don->creer)
100
-	    {
101
-	        if ($action != 'classify')
102
-	            // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
103
-	            if ($action == 'classify') {
93
+    $morehtmlref='<div class="refidno">';
94
+    // Project
95
+    if (! empty($conf->projet->enabled))
96
+    {
97
+        $langs->load("projects");
98
+        $morehtmlref.=$langs->trans('Project') . ' ';
99
+        if ($user->rights->don->creer)
100
+        {
101
+            if ($action != 'classify')
102
+                // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
103
+                if ($action == 'classify') {
104 104
                     $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">';
105
-	                $morehtmlref.='<input type="hidden" name="action" value="classin">';
106
-	                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
107
-	                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
108
-	                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
109
-	                $morehtmlref.='</form>';
110
-	            } else {
105
+                    $morehtmlref.='<input type="hidden" name="action" value="classin">';
106
+                    $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
107
+                    $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
108
+                    $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
109
+                    $morehtmlref.='</form>';
110
+                } else {
111 111
                     $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '&id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
112
-	            }
113
-	    } else {
114
-	        if (! empty($object->fk_project)) {
115
-	            $proj = new Project($db);
116
-	            $proj->fetch($object->fk_project);
112
+                }
113
+        } else {
114
+            if (! empty($object->fk_project)) {
115
+                $proj = new Project($db);
116
+                $proj->fetch($object->fk_project);
117 117
                 $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
118
-	            $morehtmlref.=$proj->ref;
119
-	            $morehtmlref.='</a>';
120
-	        } else {
121
-	            $morehtmlref.='';
122
-	        }
123
-	    }
124
-	}
125
-	$morehtmlref.='</div>';
118
+                $morehtmlref.=$proj->ref;
119
+                $morehtmlref.='</a>';
120
+            } else {
121
+                $morehtmlref.='';
122
+            }
123
+        }
124
+    }
125
+    $morehtmlref.='</div>';
126 126
 
127
-	dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
127
+    dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
128 128
 
129
-	print '<div class="fichecenter">';
130
-	print '<div class="underbanner clearboth"></div>';
129
+    print '<div class="fichecenter">';
130
+    print '<div class="underbanner clearboth"></div>';
131 131
 
132
-	$cssclass="titlefield";
133
-	include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
132
+    $cssclass="titlefield";
133
+    include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
134 134
 
135
-	dol_fiche_end();
135
+    dol_fiche_end();
136 136
 }
137 137
 
138 138
 llxFooter();
Please login to merge, or discard this patch.
dolibarr/htdocs/don/document.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
 if ($action == 'classin' && $user->rights->don->creer)
87 87
 {
88
-	$object->fetch($id);
89
-	$object->setProject($projectid);
88
+    $object->fetch($id);
89
+    $object->setProject($projectid);
90 90
 }
91 91
 
92 92
 /*
@@ -103,75 +103,75 @@  discard block
 block discarded – undo
103 103
 
104 104
 if ($object->id)
105 105
 {
106
-	$object->fetch_thirdparty();
106
+    $object->fetch_thirdparty();
107 107
 
108
-	$head=donation_prepare_head($object);
108
+    $head=donation_prepare_head($object);
109 109
 
110
-	dol_fiche_head($head, 'documents',  $langs->trans("Donation"), -1, 'generic');
110
+    dol_fiche_head($head, 'documents',  $langs->trans("Donation"), -1, 'generic');
111 111
 
112 112
 
113
-	// Build file list
114
-	$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
115
-	$totalsize=0;
116
-	foreach($filearray as $key => $file)
117
-	{
118
-		$totalsize+=$file['size'];
119
-	}
113
+    // Build file list
114
+    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
115
+    $totalsize=0;
116
+    foreach($filearray as $key => $file)
117
+    {
118
+        $totalsize+=$file['size'];
119
+    }
120 120
 
121 121
     // $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
122 122
     $linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
123 123
 
124
-	$morehtmlref='<div class="refidno">';
125
-	// Project
126
-	if (! empty($conf->projet->enabled))
127
-	{
128
-	    $langs->load("projects");
129
-	    $morehtmlref.=$langs->trans('Project') . ' ';
130
-	    if ($user->rights->don->creer)
131
-	    {
132
-	        if ($action != 'classify')
133
-	            // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
134
-	            if ($action == 'classify') {
124
+    $morehtmlref='<div class="refidno">';
125
+    // Project
126
+    if (! empty($conf->projet->enabled))
127
+    {
128
+        $langs->load("projects");
129
+        $morehtmlref.=$langs->trans('Project') . ' ';
130
+        if ($user->rights->don->creer)
131
+        {
132
+            if ($action != 'classify')
133
+                // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
134
+                if ($action == 'classify') {
135 135
                     $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">';
136
-	                $morehtmlref.='<input type="hidden" name="action" value="classin">';
137
-	                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
138
-	                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
139
-	                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
140
-	                $morehtmlref.='</form>';
141
-	            } else {
136
+                    $morehtmlref.='<input type="hidden" name="action" value="classin">';
137
+                    $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
138
+                    $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
139
+                    $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
140
+                    $morehtmlref.='</form>';
141
+                } else {
142 142
                     $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '&id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
143
-	            }
144
-	    } else {
145
-	        if (! empty($object->fk_project)) {
146
-	            $proj = new Project($db);
147
-	            $proj->fetch($object->fk_project);
143
+                }
144
+        } else {
145
+            if (! empty($object->fk_project)) {
146
+                $proj = new Project($db);
147
+                $proj->fetch($object->fk_project);
148 148
                 $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
149 149
                 $morehtmlref .= $proj->ref;
150
-	            $morehtmlref.='</a>';
151
-	        } else {
152
-	            $morehtmlref.='';
153
-	        }
154
-	    }
155
-	}
156
-	$morehtmlref.='</div>';
150
+                $morehtmlref.='</a>';
151
+            } else {
152
+                $morehtmlref.='';
153
+            }
154
+        }
155
+    }
156
+    $morehtmlref.='</div>';
157 157
 
158 158
 
159
-	dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
159
+    dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
160 160
 
161
-	print '<div class="fichecenter">';
162
-	print '<div class="underbanner clearboth"></div>';
161
+    print '<div class="fichecenter">';
162
+    print '<div class="underbanner clearboth"></div>';
163 163
 
164 164
     print '<table class="border" width="100%">';
165 165
 
166
-	// Ref
167
-	/*
166
+    // Ref
167
+    /*
168 168
 	print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
169 169
 	print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
170 170
 	print '</td></tr>';
171 171
     */
172 172
 
173
-	// Societe
174
-	//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
173
+    // Societe
174
+    //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
175 175
 
176 176
     print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
177 177
     print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>';
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 }
192 192
 else
193 193
 {
194
-	print $langs->trans("ErrorUnknown");
194
+    print $langs->trans("ErrorUnknown");
195 195
 }
196 196
 
197 197
 llxFooter();
Please login to merge, or discard this patch.
dolibarr/htdocs/compta/facture/invoicetemplate_list.php 1 patch
Indentation   +496 added lines, -496 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39 39
 if (! empty($conf->projet->enabled)) {
40
-	require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
41
-	//require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
40
+    require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
41
+    //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
42 42
 }
43 43
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
44 44
 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 $object = new FactureRec($db);
99 99
 if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
100 100
 {
101
-	$ret = $object->fetch($id, $ref);
102
-	if (!$ret)
103
-	{
104
-		setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
105
-	}
101
+    $ret = $object->fetch($id, $ref);
102
+    if (!$ret)
103
+    {
104
+        setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
105
+    }
106 106
 }
107 107
 
108 108
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -118,30 +118,30 @@  discard block
 block discarded – undo
118 118
 $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
119 119
 
120 120
 $arrayfields=array(
121
-	'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
122
-	's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
123
-	'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
124
-	'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
125
-	'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
126
-	'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0),
127
-	'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0),
128
-	'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
129
-	'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
130
-	'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
131
-	'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1),
132
-	'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGenerationShort"), 'checked'=>1),
133
-	'f.date_when'=>array('label'=>$langs->trans("NextDateToExecutionShort"), 'checked'=>1),
134
-	'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
135
-	'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
136
-	'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
121
+    'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
122
+    's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
123
+    'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
124
+    'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
125
+    'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
126
+    'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0),
127
+    'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0),
128
+    'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
129
+    'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
130
+    'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
131
+    'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1),
132
+    'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGenerationShort"), 'checked'=>1),
133
+    'f.date_when'=>array('label'=>$langs->trans("NextDateToExecutionShort"), 'checked'=>1),
134
+    'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
135
+    'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
136
+    'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
137 137
 );
138 138
 // Extra fields
139 139
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
140 140
 {
141
-	foreach($extrafields->attribute_label as $key => $val)
142
-	{
143
-		if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
144
-	}
141
+    foreach($extrafields->attribute_label as $key => $val)
142
+    {
143
+        if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
144
+    }
145 145
 }
146 146
 
147 147
 
@@ -158,36 +158,36 @@  discard block
 block discarded – undo
158 158
 
159 159
 if (empty($reshook))
160 160
 {
161
-	if (GETPOST('cancel','alpha')) $action='';
162
-
163
-	// Selection of new fields
164
-	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
165
-
166
-	// Do we click on purge search criteria ?
167
-	if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
168
-	{
169
-		$search_ref='';
170
-		$search_societe='';
171
-		$search_montant_ht='';
172
-		$search_montant_vat='';
173
-		$search_montant_ttc='';
174
-		$search_payment_mode='';
175
-		$search_payment_term='';
176
-		$search_day='';
177
-		$search_year='';
178
-		$search_month='';
179
-		$search_day_date_when='';
180
-		$search_year_date_when='';
181
-		$search_month_date_when='';
182
-		$search_recurring='';
183
-		$search_frequency='';
184
-		$search_unit_frequency='';
185
-		$search_status='';
186
-		$search_array_options=array();
187
-	}
188
-
189
-	// Mass actions
190
-	/*$objectclass='MyObject';
161
+    if (GETPOST('cancel','alpha')) $action='';
162
+
163
+    // Selection of new fields
164
+    include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
165
+
166
+    // Do we click on purge search criteria ?
167
+    if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
168
+    {
169
+        $search_ref='';
170
+        $search_societe='';
171
+        $search_montant_ht='';
172
+        $search_montant_vat='';
173
+        $search_montant_ttc='';
174
+        $search_payment_mode='';
175
+        $search_payment_term='';
176
+        $search_day='';
177
+        $search_year='';
178
+        $search_month='';
179
+        $search_day_date_when='';
180
+        $search_year_date_when='';
181
+        $search_month_date_when='';
182
+        $search_recurring='';
183
+        $search_frequency='';
184
+        $search_unit_frequency='';
185
+        $search_status='';
186
+        $search_array_options=array();
187
+    }
188
+
189
+    // Mass actions
190
+    /*$objectclass='MyObject';
191 191
     $objectlabel='MyObject';
192 192
     $permtoread = $user->rights->mymodule->read;
193 193
     $permtodelete = $user->rights->mymodule->delete;
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 $sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
223 223
 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
224 224
 if (! $user->rights->societe->client->voir && ! $socid) {
225
-	$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
225
+    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
226 226
 }
227 227
 $sql.= " WHERE f.fk_soc = s.rowid";
228 228
 $sql.= ' AND f.entity IN ('.getEntity('invoice').')';
229 229
 if (! $user->rights->societe->client->voir && ! $socid) {
230
-	$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
230
+    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
231 231
 }
232 232
 if ($search_ref)                  $sql .= natural_search('f.titre', $search_ref);
233 233
 if ($search_societe)              $sql .= natural_search('s.nom', $search_societe);
@@ -242,35 +242,35 @@  discard block
 block discarded – undo
242 242
 if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency);
243 243
 if ($search_status != '' && $search_status >= -1)
244 244
 {
245
-	if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0';
246
-	if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0';
247
-	if ($search_status == -1) $sql.= ' AND suspended = 1';
245
+    if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0';
246
+    if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0';
247
+    if ($search_status == -1) $sql.= ' AND suspended = 1';
248 248
 }
249 249
 if ($search_month > 0)
250 250
 {
251
-	if ($search_year > 0 && empty($search_day))
252
-		$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
253
-	else if ($search_year > 0 && ! empty($search_day))
254
-		$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
255
-	else
256
-		$sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'";
251
+    if ($search_year > 0 && empty($search_day))
252
+        $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
253
+    else if ($search_year > 0 && ! empty($search_day))
254
+        $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
255
+    else
256
+        $sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'";
257 257
 }
258 258
 else if ($search_year > 0)
259 259
 {
260
-	$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
260
+    $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
261 261
 }
262 262
 if ($search_month_date_when > 0)
263 263
 {
264
-	if ($search_year_date_when > 0 && empty($search_day_date_when))
265
-		$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'";
266
-	else if ($search_year_date_when > 0 && ! empty($search_day_date_when))
267
-		$sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'";
268
-	else
269
-		$sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'";
264
+    if ($search_year_date_when > 0 && empty($search_day_date_when))
265
+        $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'";
266
+    else if ($search_year_date_when > 0 && ! empty($search_day_date_when))
267
+        $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'";
268
+    else
269
+        $sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'";
270 270
 }
271 271
 else if ($search_year_date_when > 0)
272 272
 {
273
-	$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'";
273
+    $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'";
274 274
 }
275 275
 
276 276
 $sql.= $db->order($sortfield, $sortorder);
@@ -278,13 +278,13 @@  discard block
 block discarded – undo
278 278
 $nbtotalofrecords = '';
279 279
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
280 280
 {
281
-	$result = $db->query($sql);
282
-	$nbtotalofrecords = $db->num_rows($result);
283
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
284
-	{
285
-		$page = 0;
286
-		$offset = 0;
287
-	}
281
+    $result = $db->query($sql);
282
+    $nbtotalofrecords = $db->num_rows($result);
283
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
284
+    {
285
+        $page = 0;
286
+        $offset = 0;
287
+    }
288 288
 }
289 289
 
290 290
 $sql.= $db->plimit($limit+1,$offset);
@@ -292,423 +292,423 @@  discard block
 block discarded – undo
292 292
 $resql = $db->query($sql);
293 293
 if ($resql)
294 294
 {
295
-	$num = $db->num_rows($resql);
296
-
297
-	$param='';
298
-	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
299
-	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
300
-	if ($socid)                     $param.='&socid='.urlencode($socid);
301
-	if ($search_day)                $param.='&search_day='.urlencode($search_day);
302
-	if ($search_month)              $param.='&search_month='.urlencode($search_month);
303
-	if ($search_year)               $param.='&search_year=' .urlencode($search_year);
304
-	if ($search_day_date_when)      $param.='&search_day_date_when='.urlencode($search_day_date_when);
305
-	if ($search_month_date_when)    $param.='&search_month_date_when='.urlencode($search_month_date_when);
306
-	if ($search_year_date_when)     $param.='&search_year_date_when=' .urlencode($search_year_date_when);
307
-	if ($search_ref)                $param.='&search_ref=' .urlencode($search_ref);
308
-	if ($search_societe)            $param.='&search_societe=' .urlencode($search_societe);
309
-	if ($search_montant_ht != '')   $param.='&search_montant_ht=' .urlencode($search_montant_ht);
310
-	if ($search_montant_vat != '')  $param.='&search_montant_vat='.urlencode($search_montant_vat);
311
-	if ($search_montant_ttc != '')  $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
312
-	if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode);
313
-	if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type);
314
-	if ($search_recurring != '' && $search_recurrning != '-1')    $param.='&search_recurring='  .urlencode($search_recurring);
315
-	if ($search_frequency > 0)        $param.='&search_frequency='  .urlencode($search_frequency);
316
-	if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency);
317
-	if ($search_status != '')		$param.='&search_status='.urlencode($search_status);
318
-	if ($option)                    $param.="&option=".urlencode($option);
319
-	if ($optioncss != '')           $param.='&optioncss='.urlencode($optioncss);
320
-	// Add $param from extra fields
321
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
322
-
323
-	$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
324
-
325
-	$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
326
-	$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
327
-	//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
328
-
329
-	print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
330
-	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
331
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
332
-	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
333
-	print '<input type="hidden" name="action" value="list">';
334
-	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
335
-	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
336
-	print '<input type="hidden" name="page" value="'.$page.'">';
337
-	print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
338
-	print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
339
-
340
-	print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
341
-
342
-	print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
343
-
344
-	$i = 0;
345
-
346
-	print '<div class="div-table-responsive">';
347
-	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
348
-
349
-	// Filters lines
350
-	print '<tr class="liste_titre_filter">';
351
-	// Ref
352
-	if (! empty($arrayfields['f.titre']['checked']))
353
-	{
354
-		print '<td class="liste_titre" align="left">';
355
-		print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
356
-		print '</td>';
357
-	}
358
-	// Thirpdarty
359
-	if (! empty($arrayfields['s.nom']['checked']))
360
-	{
361
-		print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
362
-	}
363
-	if (! empty($arrayfields['f.total']['checked']))
364
-	{
365
-		// Amount net
366
-		print '<td class="liste_titre" align="right">';
367
-		print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
368
-		print '</td>';
369
-	}
370
-	if (! empty($arrayfields['f.tva']['checked']))
371
-	{
372
-		// Amount Vat
373
-		print '<td class="liste_titre" align="right">';
374
-		print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
375
-		print '</td>';
376
-	}
377
-	if (! empty($arrayfields['f.total_ttc']['checked']))
378
-	{
379
-		// Amount
380
-		print '<td class="liste_titre" align="right">';
381
-		print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
382
-		print '</td>';
383
-	}
384
-	if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
385
-	{
386
-		// Payment term
387
-		print '<td class="liste_titre" align="right">';
388
-		print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
389
-		print "</td>";
390
-	}
391
-	if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
392
-	{
393
-		// Payment mode
394
-		print '<td class="liste_titre" align="right">';
395
-		print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
396
-		print '</td>';
397
-	}
398
-	if (! empty($arrayfields['recurring']['checked']))
399
-	{
400
-		// Recurring or not
401
-		print '<td class="liste_titre" align="center">';
402
-		print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
403
-		print '</td>';
404
-	}
405
-	if (! empty($arrayfields['f.frequency']['checked']))
406
-	{
407
-		// Recurring or not
408
-		print '<td class="liste_titre" align="center">';
409
-		print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
410
-		print '</td>';
411
-	}
412
-	if (! empty($arrayfields['f.unit_frequency']['checked']))
413
-	{
414
-		// Frequency unit
415
-		print '<td class="liste_titre" align="center">';
416
-		print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
417
-		print '</td>';
418
-	}
419
-	if (! empty($arrayfields['f.nb_gen_done']['checked']))
420
-	{
421
-		// Nb generation
422
-		print '<td class="liste_titre" align="center">';
423
-		print '</td>';
424
-	}
425
-	// Date invoice
426
-	if (! empty($arrayfields['f.date_last_gen']['checked']))
427
-	{
428
-		print '<td class="liste_titre nowraponall" align="center">';
429
-		if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
430
-		print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
431
-		$formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle');
432
-		print '</td>';
433
-	}
434
-	// Date next generation
435
-	if (! empty($arrayfields['f.date_when']['checked']))
436
-	{
437
-		print '<td class="liste_titre nowraponall" align="center">';
438
-		if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">';
439
-		print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">';
440
-		$formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle');
441
-		print '</td>';
442
-	}
443
-	// Extra fields
444
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
445
-
446
-	// Fields from hook
447
-	$parameters=array('arrayfields'=>$arrayfields);
448
-	$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
449
-	print $hookmanager->resPrint;
450
-	// Date creation
451
-	if (! empty($arrayfields['f.datec']['checked']))
452
-	{
453
-		print '<td class="liste_titre">';
454
-		print '</td>';
455
-	}
456
-	// Date modification
457
-	if (! empty($arrayfields['f.tms']['checked']))
458
-	{
459
-		print '<td class="liste_titre">';
460
-		print '</td>';
461
-	}
462
-	// Status
463
-	if (! empty($arrayfields['status']['checked']))
464
-	{
465
-		print '<td class="liste_titre" align="center">';
466
-		$liststatus=array(
467
-			0=>$langs->trans("Draft"),
468
-			1=>$langs->trans("Active"),
469
-			-1=>$langs->trans("Disabled"),
470
-		);
471
-		print $form->selectarray('search_status', $liststatus, $search_status, -2);
472
-		print '</td>';
473
-	}
474
-	// Action column
475
-	print '<td class="liste_titre" align="middle">';
476
-	$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
477
-	print $searchpicto;
478
-	print '</td>';
479
-	print "</tr>\n";
480
-
481
-
482
-	print '<tr class="liste_titre">';
483
-	if (! empty($arrayfields['f.titre']['checked']))         print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
484
-	if (! empty($arrayfields['s.nom']['checked']))           print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
485
-	if (! empty($arrayfields['f.total']['checked']))         print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
486
-	if (! empty($arrayfields['f.tva']['checked']))           print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
487
-	if (! empty($arrayfields['f.total_ttc']['checked']))     print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
488
-	if (! empty($arrayfields['f.fk_cond_reglement']['checked']))     print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder);
489
-	if (! empty($arrayfields['f.fk_mode_reglement']['checked']))     print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder);
490
-	if (! empty($arrayfields['recurring']['checked']))       print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder);
491
-	if (! empty($arrayfields['f.frequency']['checked']))     print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
492
-	if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder);
493
-	if (! empty($arrayfields['f.nb_gen_done']['checked']))   print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
494
-	if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
495
-	if (! empty($arrayfields['f.date_when']['checked']))     print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
496
-	if (! empty($arrayfields['f.datec']['checked']))         print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
497
-	if (! empty($arrayfields['f.tms']['checked']))           print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
498
-	if (! empty($arrayfields['status']['checked']))          print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder);
499
-	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n";
500
-	print "</tr>\n";
501
-
502
-	if ($num > 0)
503
-	{
504
-		$i=0;
505
-		$totalarray=array();
506
-		while ($i < min($num,$limit))
507
-		{
508
-			$objp = $db->fetch_object($resql);
509
-			if (empty($objp)) break;
510
-
511
-			$companystatic->id=$objp->socid;
512
-			$companystatic->name=$objp->name;
513
-
514
-			$invoicerectmp->id=$objp->id?$objp->id:$objp->facid;
515
-			$invoicerectmp->frequency=$objp->frequency;
516
-			$invoicerectmp->suspended=$objp->suspended;
517
-			$invoicerectmp->unit_frequency=$objp->unit_frequency;
518
-			$invoicerectmp->nb_gen_max=$objp->nb_gen_max;
519
-			$invoicerectmp->nb_gen_done=$objp->nb_gen_done;
520
-			$invoicerectmp->ref=$objp->titre;
521
-
522
-			print '<tr class="oddeven">';
523
-
524
-			if (! empty($arrayfields['f.titre']['checked']))
525
-			{
526
-			   print '<td>';
527
-			   print $invoicerectmp->getNomUrl(1);
528
-			   print "</a>";
529
-			   print "</td>\n";
530
-			   if (! $i) $totalarray['nbfield']++;
531
-			}
532
-			if (! empty($arrayfields['s.nom']['checked']))
533
-			{
534
-			   print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
535
-			   if (! $i) $totalarray['nbfield']++;
536
-			}
537
-			if (! empty($arrayfields['f.total']['checked']))
538
-			{
539
-			   print '<td align="right">'.price($objp->total).'</td>'."\n";
540
-			   if (! $i) $totalarray['nbfield']++;
541
-			   if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total';
542
-			   $totalarray['val']['f.total'] += $objp->total;
543
-			}
544
-			if (! empty($arrayfields['f.tva']['checked']))
545
-			{
546
-			   print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
547
-			   if (! $i) $totalarray['nbfield']++;
548
-			   if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva';
549
-			   $totalarray['val']['f.tva'] += $objp->total_vat;
550
-			}
551
-			if (! empty($arrayfields['f.total_ttc']['checked']))
552
-			{
553
-			   print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
554
-			   if (! $i) $totalarray['nbfield']++;
555
-			   if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
556
-			   $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
557
-			}
558
-			// Payment term
559
-			if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
560
-			{
561
-			   print '<td align="right">';
562
-			   print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
563
-			   print '</td>'."\n";
564
-			   if (! $i) $totalarray['nbfield']++;
565
-			}
566
-			// Payment mode
567
-			if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
568
-			{
569
-			   print '<td align="right">';
570
-			   print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
571
-			   print '</td>'."\n";
572
-			   if (! $i) $totalarray['nbfield']++;
573
-			}
574
-			if (! empty($arrayfields['recurring']['checked']))
575
-			{
576
-			   print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
577
-			   if (! $i) $totalarray['nbfield']++;
578
-			}
579
-			if (! empty($arrayfields['f.frequency']['checked']))
580
-			{
581
-			   print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
582
-			   if (! $i) $totalarray['nbfield']++;
583
-			}
584
-			if (! empty($arrayfields['f.unit_frequency']['checked']))
585
-			{
586
-			   print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
587
-			   if (! $i) $totalarray['nbfield']++;
588
-			}
589
-			if (! empty($arrayfields['f.nb_gen_done']['checked']))
590
-			{
591
-				print '<td align="center">';
592
-				print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
593
-				print '</td>';
594
-				if (! $i) $totalarray['nbfield']++;
595
-			}
596
-			// Date last generation
597
-			if (! empty($arrayfields['f.date_last_gen']['checked']))
598
-			{
599
-			   print '<td align="center">';
600
-			   print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
601
-			   print '</td>';
602
-			   if (! $i) $totalarray['nbfield']++;
603
-			}
604
-			// Date next generation
605
-			if (! empty($arrayfields['f.date_when']['checked']))
606
-			{
607
-				print '<td align="center">';
608
-				print '<div class="nowraponall">';
609
-				print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
610
-				if (! $invoicerectmp->isMaxNbGenReached())
611
-				{
612
-					if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
613
-				}
614
-				else
615
-				{
616
-					print img_info($langs->trans("MaxNumberOfGenerationReached"));
617
-				}
618
-				print '</div>';
619
-				print '</td>';
620
-				if (! $i) $totalarray['nbfield']++;
621
-			}
622
-			if (! empty($arrayfields['f.datec']['checked']))
623
-			{
624
-			   print '<td align="center">';
625
-			   print dol_print_date($db->jdate($objp->datec),'dayhour');
626
-			   print '</td>';
627
-			   if (! $i) $totalarray['nbfield']++;
628
-			}
629
-			if (! empty($arrayfields['f.tms']['checked']))
630
-			{
631
-			   print '<td align="center">';
632
-			   print dol_print_date($db->jdate($objp->tms),'dayhour');
633
-			   print '</td>';
634
-			   if (! $i) $totalarray['nbfield']++;
635
-			}
636
-			if (! empty($arrayfields['status']['checked']))
637
-			{
638
-			   print '<td align="center">';
639
-			   print $invoicerectmp->getLibStatut(3,0);
640
-			   print '</td>';
641
-			   if (! $i) $totalarray['nbfield']++;
642
-			}
643
-			// Action column
644
-			print '<td align="center">';
645
-			if ($user->rights->facture->creer && empty($invoicerectmp->suspended))
646
-			{
647
-				if ($invoicerectmp->isMaxNbGenReached())
648
-				{
649
-					print $langs->trans("MaxNumberOfGenerationReached");
650
-				}
651
-				elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
652
-				{
295
+    $num = $db->num_rows($resql);
296
+
297
+    $param='';
298
+    if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
299
+    if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
300
+    if ($socid)                     $param.='&socid='.urlencode($socid);
301
+    if ($search_day)                $param.='&search_day='.urlencode($search_day);
302
+    if ($search_month)              $param.='&search_month='.urlencode($search_month);
303
+    if ($search_year)               $param.='&search_year=' .urlencode($search_year);
304
+    if ($search_day_date_when)      $param.='&search_day_date_when='.urlencode($search_day_date_when);
305
+    if ($search_month_date_when)    $param.='&search_month_date_when='.urlencode($search_month_date_when);
306
+    if ($search_year_date_when)     $param.='&search_year_date_when=' .urlencode($search_year_date_when);
307
+    if ($search_ref)                $param.='&search_ref=' .urlencode($search_ref);
308
+    if ($search_societe)            $param.='&search_societe=' .urlencode($search_societe);
309
+    if ($search_montant_ht != '')   $param.='&search_montant_ht=' .urlencode($search_montant_ht);
310
+    if ($search_montant_vat != '')  $param.='&search_montant_vat='.urlencode($search_montant_vat);
311
+    if ($search_montant_ttc != '')  $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
312
+    if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode);
313
+    if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type);
314
+    if ($search_recurring != '' && $search_recurrning != '-1')    $param.='&search_recurring='  .urlencode($search_recurring);
315
+    if ($search_frequency > 0)        $param.='&search_frequency='  .urlencode($search_frequency);
316
+    if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency);
317
+    if ($search_status != '')		$param.='&search_status='.urlencode($search_status);
318
+    if ($option)                    $param.="&option=".urlencode($option);
319
+    if ($optioncss != '')           $param.='&optioncss='.urlencode($optioncss);
320
+    // Add $param from extra fields
321
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
322
+
323
+    $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
324
+
325
+    $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
326
+    $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
327
+    //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
328
+
329
+    print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
330
+    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
331
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
332
+    print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
333
+    print '<input type="hidden" name="action" value="list">';
334
+    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
335
+    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
336
+    print '<input type="hidden" name="page" value="'.$page.'">';
337
+    print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
338
+    print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
339
+
340
+    print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
341
+
342
+    print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
343
+
344
+    $i = 0;
345
+
346
+    print '<div class="div-table-responsive">';
347
+    print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
348
+
349
+    // Filters lines
350
+    print '<tr class="liste_titre_filter">';
351
+    // Ref
352
+    if (! empty($arrayfields['f.titre']['checked']))
353
+    {
354
+        print '<td class="liste_titre" align="left">';
355
+        print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
356
+        print '</td>';
357
+    }
358
+    // Thirpdarty
359
+    if (! empty($arrayfields['s.nom']['checked']))
360
+    {
361
+        print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
362
+    }
363
+    if (! empty($arrayfields['f.total']['checked']))
364
+    {
365
+        // Amount net
366
+        print '<td class="liste_titre" align="right">';
367
+        print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
368
+        print '</td>';
369
+    }
370
+    if (! empty($arrayfields['f.tva']['checked']))
371
+    {
372
+        // Amount Vat
373
+        print '<td class="liste_titre" align="right">';
374
+        print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
375
+        print '</td>';
376
+    }
377
+    if (! empty($arrayfields['f.total_ttc']['checked']))
378
+    {
379
+        // Amount
380
+        print '<td class="liste_titre" align="right">';
381
+        print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
382
+        print '</td>';
383
+    }
384
+    if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
385
+    {
386
+        // Payment term
387
+        print '<td class="liste_titre" align="right">';
388
+        print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
389
+        print "</td>";
390
+    }
391
+    if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
392
+    {
393
+        // Payment mode
394
+        print '<td class="liste_titre" align="right">';
395
+        print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
396
+        print '</td>';
397
+    }
398
+    if (! empty($arrayfields['recurring']['checked']))
399
+    {
400
+        // Recurring or not
401
+        print '<td class="liste_titre" align="center">';
402
+        print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
403
+        print '</td>';
404
+    }
405
+    if (! empty($arrayfields['f.frequency']['checked']))
406
+    {
407
+        // Recurring or not
408
+        print '<td class="liste_titre" align="center">';
409
+        print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
410
+        print '</td>';
411
+    }
412
+    if (! empty($arrayfields['f.unit_frequency']['checked']))
413
+    {
414
+        // Frequency unit
415
+        print '<td class="liste_titre" align="center">';
416
+        print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
417
+        print '</td>';
418
+    }
419
+    if (! empty($arrayfields['f.nb_gen_done']['checked']))
420
+    {
421
+        // Nb generation
422
+        print '<td class="liste_titre" align="center">';
423
+        print '</td>';
424
+    }
425
+    // Date invoice
426
+    if (! empty($arrayfields['f.date_last_gen']['checked']))
427
+    {
428
+        print '<td class="liste_titre nowraponall" align="center">';
429
+        if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
430
+        print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
431
+        $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle');
432
+        print '</td>';
433
+    }
434
+    // Date next generation
435
+    if (! empty($arrayfields['f.date_when']['checked']))
436
+    {
437
+        print '<td class="liste_titre nowraponall" align="center">';
438
+        if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">';
439
+        print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">';
440
+        $formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle');
441
+        print '</td>';
442
+    }
443
+    // Extra fields
444
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
445
+
446
+    // Fields from hook
447
+    $parameters=array('arrayfields'=>$arrayfields);
448
+    $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
449
+    print $hookmanager->resPrint;
450
+    // Date creation
451
+    if (! empty($arrayfields['f.datec']['checked']))
452
+    {
453
+        print '<td class="liste_titre">';
454
+        print '</td>';
455
+    }
456
+    // Date modification
457
+    if (! empty($arrayfields['f.tms']['checked']))
458
+    {
459
+        print '<td class="liste_titre">';
460
+        print '</td>';
461
+    }
462
+    // Status
463
+    if (! empty($arrayfields['status']['checked']))
464
+    {
465
+        print '<td class="liste_titre" align="center">';
466
+        $liststatus=array(
467
+            0=>$langs->trans("Draft"),
468
+            1=>$langs->trans("Active"),
469
+            -1=>$langs->trans("Disabled"),
470
+        );
471
+        print $form->selectarray('search_status', $liststatus, $search_status, -2);
472
+        print '</td>';
473
+    }
474
+    // Action column
475
+    print '<td class="liste_titre" align="middle">';
476
+    $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
477
+    print $searchpicto;
478
+    print '</td>';
479
+    print "</tr>\n";
480
+
481
+
482
+    print '<tr class="liste_titre">';
483
+    if (! empty($arrayfields['f.titre']['checked']))         print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
484
+    if (! empty($arrayfields['s.nom']['checked']))           print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
485
+    if (! empty($arrayfields['f.total']['checked']))         print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
486
+    if (! empty($arrayfields['f.tva']['checked']))           print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
487
+    if (! empty($arrayfields['f.total_ttc']['checked']))     print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
488
+    if (! empty($arrayfields['f.fk_cond_reglement']['checked']))     print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder);
489
+    if (! empty($arrayfields['f.fk_mode_reglement']['checked']))     print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder);
490
+    if (! empty($arrayfields['recurring']['checked']))       print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder);
491
+    if (! empty($arrayfields['f.frequency']['checked']))     print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
492
+    if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder);
493
+    if (! empty($arrayfields['f.nb_gen_done']['checked']))   print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
494
+    if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
495
+    if (! empty($arrayfields['f.date_when']['checked']))     print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
496
+    if (! empty($arrayfields['f.datec']['checked']))         print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
497
+    if (! empty($arrayfields['f.tms']['checked']))           print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
498
+    if (! empty($arrayfields['status']['checked']))          print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder);
499
+    print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n";
500
+    print "</tr>\n";
501
+
502
+    if ($num > 0)
503
+    {
504
+        $i=0;
505
+        $totalarray=array();
506
+        while ($i < min($num,$limit))
507
+        {
508
+            $objp = $db->fetch_object($resql);
509
+            if (empty($objp)) break;
510
+
511
+            $companystatic->id=$objp->socid;
512
+            $companystatic->name=$objp->name;
513
+
514
+            $invoicerectmp->id=$objp->id?$objp->id:$objp->facid;
515
+            $invoicerectmp->frequency=$objp->frequency;
516
+            $invoicerectmp->suspended=$objp->suspended;
517
+            $invoicerectmp->unit_frequency=$objp->unit_frequency;
518
+            $invoicerectmp->nb_gen_max=$objp->nb_gen_max;
519
+            $invoicerectmp->nb_gen_done=$objp->nb_gen_done;
520
+            $invoicerectmp->ref=$objp->titre;
521
+
522
+            print '<tr class="oddeven">';
523
+
524
+            if (! empty($arrayfields['f.titre']['checked']))
525
+            {
526
+                print '<td>';
527
+                print $invoicerectmp->getNomUrl(1);
528
+                print "</a>";
529
+                print "</td>\n";
530
+                if (! $i) $totalarray['nbfield']++;
531
+            }
532
+            if (! empty($arrayfields['s.nom']['checked']))
533
+            {
534
+                print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
535
+                if (! $i) $totalarray['nbfield']++;
536
+            }
537
+            if (! empty($arrayfields['f.total']['checked']))
538
+            {
539
+                print '<td align="right">'.price($objp->total).'</td>'."\n";
540
+                if (! $i) $totalarray['nbfield']++;
541
+                if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total';
542
+                $totalarray['val']['f.total'] += $objp->total;
543
+            }
544
+            if (! empty($arrayfields['f.tva']['checked']))
545
+            {
546
+                print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
547
+                if (! $i) $totalarray['nbfield']++;
548
+                if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva';
549
+                $totalarray['val']['f.tva'] += $objp->total_vat;
550
+            }
551
+            if (! empty($arrayfields['f.total_ttc']['checked']))
552
+            {
553
+                print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
554
+                if (! $i) $totalarray['nbfield']++;
555
+                if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
556
+                $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
557
+            }
558
+            // Payment term
559
+            if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
560
+            {
561
+                print '<td align="right">';
562
+                print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
563
+                print '</td>'."\n";
564
+                if (! $i) $totalarray['nbfield']++;
565
+            }
566
+            // Payment mode
567
+            if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
568
+            {
569
+                print '<td align="right">';
570
+                print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
571
+                print '</td>'."\n";
572
+                if (! $i) $totalarray['nbfield']++;
573
+            }
574
+            if (! empty($arrayfields['recurring']['checked']))
575
+            {
576
+                print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
577
+                if (! $i) $totalarray['nbfield']++;
578
+            }
579
+            if (! empty($arrayfields['f.frequency']['checked']))
580
+            {
581
+                print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
582
+                if (! $i) $totalarray['nbfield']++;
583
+            }
584
+            if (! empty($arrayfields['f.unit_frequency']['checked']))
585
+            {
586
+                print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
587
+                if (! $i) $totalarray['nbfield']++;
588
+            }
589
+            if (! empty($arrayfields['f.nb_gen_done']['checked']))
590
+            {
591
+                print '<td align="center">';
592
+                print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
593
+                print '</td>';
594
+                if (! $i) $totalarray['nbfield']++;
595
+            }
596
+            // Date last generation
597
+            if (! empty($arrayfields['f.date_last_gen']['checked']))
598
+            {
599
+                print '<td align="center">';
600
+                print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
601
+                print '</td>';
602
+                if (! $i) $totalarray['nbfield']++;
603
+            }
604
+            // Date next generation
605
+            if (! empty($arrayfields['f.date_when']['checked']))
606
+            {
607
+                print '<td align="center">';
608
+                print '<div class="nowraponall">';
609
+                print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
610
+                if (! $invoicerectmp->isMaxNbGenReached())
611
+                {
612
+                    if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
613
+                }
614
+                else
615
+                {
616
+                    print img_info($langs->trans("MaxNumberOfGenerationReached"));
617
+                }
618
+                print '</div>';
619
+                print '</td>';
620
+                if (! $i) $totalarray['nbfield']++;
621
+            }
622
+            if (! empty($arrayfields['f.datec']['checked']))
623
+            {
624
+                print '<td align="center">';
625
+                print dol_print_date($db->jdate($objp->datec),'dayhour');
626
+                print '</td>';
627
+                if (! $i) $totalarray['nbfield']++;
628
+            }
629
+            if (! empty($arrayfields['f.tms']['checked']))
630
+            {
631
+                print '<td align="center">';
632
+                print dol_print_date($db->jdate($objp->tms),'dayhour');
633
+                print '</td>';
634
+                if (! $i) $totalarray['nbfield']++;
635
+            }
636
+            if (! empty($arrayfields['status']['checked']))
637
+            {
638
+                print '<td align="center">';
639
+                print $invoicerectmp->getLibStatut(3,0);
640
+                print '</td>';
641
+                if (! $i) $totalarray['nbfield']++;
642
+            }
643
+            // Action column
644
+            print '<td align="center">';
645
+            if ($user->rights->facture->creer && empty($invoicerectmp->suspended))
646
+            {
647
+                if ($invoicerectmp->isMaxNbGenReached())
648
+                {
649
+                    print $langs->trans("MaxNumberOfGenerationReached");
650
+                }
651
+                elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
652
+                {
653 653
                     print '<a href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&amp;socid=' . $objp->socid . '&amp;fac_rec=' . $objp->facid . '">';
654
-					print $langs->trans("CreateBill").'</a>';
655
-				}
656
-				else
657
-				{
658
-					print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
659
-				}
660
-			}
661
-			else
662
-			{
663
-				print "&nbsp;";
664
-			}
665
-			if (! $i) $totalarray['nbfield']++;
666
-			print "</td>";
667
-
668
-			print "</tr>\n";
669
-
670
-			$i++;
671
-		}
672
-	}
673
-	else
674
-	{
675
-		$colspan=1;
676
-		foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
677
-		print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
678
-	}
679
-
680
-	//var_dump($totalarray);
681
-	// Show total line
682
-	if (isset($totalarray['pos']))
683
-	{
684
-		print '<tr class="liste_total">';
685
-		$i=0;
686
-		while ($i < $totalarray['nbfield'])
687
-		{
688
-			$i++;
689
-			if (! empty($totalarray['pos'][$i]))  print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
690
-			else
691
-			{
692
-				if ($i == 1)
693
-				{
694
-					if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
695
-					else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
696
-				}
697
-				else print '<td></td>';
698
-			}
699
-		}
700
-		print '</tr>';
701
-	}
702
-
703
-	print "</table>";
704
-	print "</div>";
705
-	print "</form>";
706
-
707
-	$db->free($resql);
654
+                    print $langs->trans("CreateBill").'</a>';
655
+                }
656
+                else
657
+                {
658
+                    print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
659
+                }
660
+            }
661
+            else
662
+            {
663
+                print "&nbsp;";
664
+            }
665
+            if (! $i) $totalarray['nbfield']++;
666
+            print "</td>";
667
+
668
+            print "</tr>\n";
669
+
670
+            $i++;
671
+        }
672
+    }
673
+    else
674
+    {
675
+        $colspan=1;
676
+        foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
677
+        print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
678
+    }
679
+
680
+    //var_dump($totalarray);
681
+    // Show total line
682
+    if (isset($totalarray['pos']))
683
+    {
684
+        print '<tr class="liste_total">';
685
+        $i=0;
686
+        while ($i < $totalarray['nbfield'])
687
+        {
688
+            $i++;
689
+            if (! empty($totalarray['pos'][$i]))  print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
690
+            else
691
+            {
692
+                if ($i == 1)
693
+                {
694
+                    if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
695
+                    else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
696
+                }
697
+                else print '<td></td>';
698
+            }
699
+        }
700
+        print '</tr>';
701
+    }
702
+
703
+    print "</table>";
704
+    print "</div>";
705
+    print "</form>";
706
+
707
+    $db->free($resql);
708 708
 }
709 709
 else
710 710
 {
711
-	dol_print_error($db);
711
+    dol_print_error($db);
712 712
 }
713 713
 
714 714
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/compta/facture/fiche-rec.php 1 patch
Indentation   +1424 added lines, -1424 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40 40
 if (! empty($conf->projet->enabled)) {
41
-	include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
42
-	//include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
41
+    include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
42
+    //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
43 43
 }
44 44
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
45 45
 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 $object = new FactureRec($db);
85 85
 if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
86 86
 {
87
-	$ret = $object->fetch($id, $ref);
88
-	if (!$ret)
89
-	{
90
-		setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
91
-	}
87
+    $ret = $object->fetch($id, $ref);
88
+    if (!$ret)
89
+    {
90
+        setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
91
+    }
92 92
 }
93 93
 
94 94
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -119,564 +119,564 @@  discard block
 block discarded – undo
119 119
 
120 120
 if (empty($reshook))
121 121
 {
122
-	if (GETPOST('cancel','alpha')) $action='';
122
+    if (GETPOST('cancel','alpha')) $action='';
123 123
 
124
-	// Selection of new fields
125
-	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
124
+    // Selection of new fields
125
+    include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
126 126
 
127
-	// Set note
128
-	include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';	    // Must be include, not include_once
127
+    // Set note
128
+    include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';	    // Must be include, not include_once
129 129
 
130
-	include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';		// Must be include, not include_once
130
+    include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';		// Must be include, not include_once
131 131
 
132
-	include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';	// Must be include, not include_once
132
+    include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';	// Must be include, not include_once
133 133
 
134
-	// Mass actions
135
-	/*$objectclass='MyObject';
134
+    // Mass actions
135
+    /*$objectclass='MyObject';
136 136
     $objectlabel='MyObject';
137 137
     $permtoread = $user->rights->mymodule->read;
138 138
     $permtodelete = $user->rights->mymodule->delete;
139 139
     $uploaddir = $conf->mymodule->dir_output;
140 140
     include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
141 141
 
142
-	// Create predefined invoice
143
-	if ($action == 'add')
144
-	{
145
-		if (! GETPOST('titre'))
146
-		{
147
-			setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), null, 'errors');
148
-			$action = "create";
149
-			$error++;
150
-		}
151
-
152
-		$frequency=GETPOST('frequency', 'int');
153
-		$reyear=GETPOST('reyear');
154
-		$remonth=GETPOST('remonth');
155
-		$reday=GETPOST('reday');
156
-		$rehour=GETPOST('rehour');
157
-		$remin=GETPOST('remin');
158
-		$nb_gen_max=GETPOST('nb_gen_max', 'int');
159
-		//if (empty($nb_gen_max)) $nb_gen_max =0;
160
-
161
-		if (GETPOST('frequency'))
162
-		{
163
-			if (empty($reyear) || empty($remonth) || empty($reday))
164
-			{
165
-				setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors');
166
-				$action = "create";
167
-				$error++;
168
-			}
169
-			if ($nb_gen_max === '')
170
-			{
171
-				setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors');
172
-				$action = "create";
173
-				$error++;
174
-			}
175
-		}
176
-
177
-		if (! $error)
178
-		{
179
-			$object->titre = GETPOST('titre', 'alpha');
180
-			$object->note_private = GETPOST('note_private','none');
142
+    // Create predefined invoice
143
+    if ($action == 'add')
144
+    {
145
+        if (! GETPOST('titre'))
146
+        {
147
+            setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), null, 'errors');
148
+            $action = "create";
149
+            $error++;
150
+        }
151
+
152
+        $frequency=GETPOST('frequency', 'int');
153
+        $reyear=GETPOST('reyear');
154
+        $remonth=GETPOST('remonth');
155
+        $reday=GETPOST('reday');
156
+        $rehour=GETPOST('rehour');
157
+        $remin=GETPOST('remin');
158
+        $nb_gen_max=GETPOST('nb_gen_max', 'int');
159
+        //if (empty($nb_gen_max)) $nb_gen_max =0;
160
+
161
+        if (GETPOST('frequency'))
162
+        {
163
+            if (empty($reyear) || empty($remonth) || empty($reday))
164
+            {
165
+                setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors');
166
+                $action = "create";
167
+                $error++;
168
+            }
169
+            if ($nb_gen_max === '')
170
+            {
171
+                setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors');
172
+                $action = "create";
173
+                $error++;
174
+            }
175
+        }
176
+
177
+        if (! $error)
178
+        {
179
+            $object->titre = GETPOST('titre', 'alpha');
180
+            $object->note_private = GETPOST('note_private','none');
181 181
             $object->note_public  = GETPOST('note_public','none');
182 182
             $object->modelpdf = GETPOST('modelpdf', 'alpha');
183
-			$object->usenewprice = GETPOST('usenewprice');
183
+            $object->usenewprice = GETPOST('usenewprice');
184 184
 
185
-			$object->frequency = $frequency;
186
-			$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
187
-			$object->nb_gen_max = $nb_gen_max;
188
-			$object->auto_validate = GETPOST('auto_validate', 'int');
185
+            $object->frequency = $frequency;
186
+            $object->unit_frequency = GETPOST('unit_frequency', 'alpha');
187
+            $object->nb_gen_max = $nb_gen_max;
188
+            $object->auto_validate = GETPOST('auto_validate', 'int');
189 189
             $object->generate_pdf = GETPOST('generate_pdf', 'int');
190
-			$object->fk_project = $projectid;
191
-
192
-			$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
193
-			$object->date_when = $date_next_execution;
194
-
195
-			// Get first contract linked to invoice used to generate template (facid is id of source invoice)
196
-			if (GETPOST('facid','int') > 0)
197
-			{
198
-				$srcObject = new Facture($db);
199
-				$srcObject->fetch(GETPOST('facid','int'));
200
-
201
-				$srcObject->fetchObjectLinked();
202
-
203
-				if (! empty($srcObject->linkedObjectsIds['contrat']))
204
-				{
205
-					$contractidid = reset($srcObject->linkedObjectsIds['contrat']);
206
-
207
-					$object->origin = 'contrat';
208
-					$object->origin_id = $contractidid;
209
-					$object->linked_objects[$object->origin] = $object->origin_id;
210
-				}
211
-			}
212
-
213
-			$db->begin();
214
-
215
-			$oldinvoice = new Facture($db);
216
-			$oldinvoice->fetch(GETPOST('facid','int'));
217
-
218
-			$result = $object->create($user, $oldinvoice->id);
219
-			if ($result > 0)
220
-			{
221
-				$result=$oldinvoice->delete($user, 1);
222
-				if ($result < 0)
223
-				{
224
-					$error++;
225
-					setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors');
226
-					$action = "create";
227
-				}
228
-			}
229
-			else
230
-			{
231
-				$error++;
232
-				setEventMessages($object->error, $object->errors, 'errors');
233
-				$action = "create";
234
-			}
235
-
236
-			if (! $error)
237
-			{
238
-				$db->commit();
239
-
240
-				header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id);
241
-	   			exit;
242
-			}
243
-			else
244
-			{
245
-				$db->rollback();
246
-
247
-				$error++;
248
-				setEventMessages($object->error, $object->errors, 'errors');
249
-				$action = "create";
250
-			}
251
-		}
252
-	}
253
-
254
-	// Delete
255
-	if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer)
256
-	{
257
-		$object->delete($user);
190
+            $object->fk_project = $projectid;
191
+
192
+            $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
193
+            $object->date_when = $date_next_execution;
194
+
195
+            // Get first contract linked to invoice used to generate template (facid is id of source invoice)
196
+            if (GETPOST('facid','int') > 0)
197
+            {
198
+                $srcObject = new Facture($db);
199
+                $srcObject->fetch(GETPOST('facid','int'));
200
+
201
+                $srcObject->fetchObjectLinked();
202
+
203
+                if (! empty($srcObject->linkedObjectsIds['contrat']))
204
+                {
205
+                    $contractidid = reset($srcObject->linkedObjectsIds['contrat']);
206
+
207
+                    $object->origin = 'contrat';
208
+                    $object->origin_id = $contractidid;
209
+                    $object->linked_objects[$object->origin] = $object->origin_id;
210
+                }
211
+            }
212
+
213
+            $db->begin();
214
+
215
+            $oldinvoice = new Facture($db);
216
+            $oldinvoice->fetch(GETPOST('facid','int'));
217
+
218
+            $result = $object->create($user, $oldinvoice->id);
219
+            if ($result > 0)
220
+            {
221
+                $result=$oldinvoice->delete($user, 1);
222
+                if ($result < 0)
223
+                {
224
+                    $error++;
225
+                    setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors');
226
+                    $action = "create";
227
+                }
228
+            }
229
+            else
230
+            {
231
+                $error++;
232
+                setEventMessages($object->error, $object->errors, 'errors');
233
+                $action = "create";
234
+            }
235
+
236
+            if (! $error)
237
+            {
238
+                $db->commit();
239
+
240
+                header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id);
241
+                    exit;
242
+            }
243
+            else
244
+            {
245
+                $db->rollback();
246
+
247
+                $error++;
248
+                setEventMessages($object->error, $object->errors, 'errors');
249
+                $action = "create";
250
+            }
251
+        }
252
+    }
253
+
254
+    // Delete
255
+    if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer)
256
+    {
257
+        $object->delete($user);
258 258
 
259 259
         header("Location: " . BASE_URI . 'controller=compta/facture&method=invoicetemplate_list');
260
-		exit;
261
-	}
262
-
263
-
264
-	// Update field
265
-	// Set condition
266
-	if ($action == 'setconditions' && $user->rights->facture->creer)
267
-	{
268
-		$result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
269
-	}
270
-	// Set mode
271
-	elseif ($action == 'setmode' && $user->rights->facture->creer)
272
-	{
273
-		$result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
274
-	}
275
-	// Set project
276
-	elseif ($action == 'classin' && $user->rights->facture->creer)
277
-	{
278
-		$object->setProject(GETPOST('projectid', 'int'));
279
-	}
280
-	// Set bank account
281
-	elseif ($action == 'setref' && $user->rights->facture->creer)
282
-	{
283
-		//var_dump(GETPOST('ref', 'alpha'));exit;
284
-		$result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY');
285
-		if ($result > 0)
286
-		{
287
-			$object->titre = GETPOST('ref', 'alpha');
288
-			$object->ref = $object->titre;
289
-		}
290
-		else dol_print_error($db, $object->error, $object->errors);
291
-	}
292
-	// Set bank account
293
-	elseif ($action == 'setbankaccount' && $user->rights->facture->creer)
294
-	{
295
-		$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
296
-	}
297
-	// Set frequency and unit frequency
298
-	elseif ($action == 'setfrequency' && $user->rights->facture->creer)
299
-	{
300
-		$object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha'));
301
-	}
302
-	// Set next date of execution
303
-	elseif ($action == 'setdate_when' && $user->rights->facture->creer)
304
-	{
305
-		$date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
306
-		if (!empty($date)) $object->setNextDate($date);
307
-	}
308
-	// Set max period
309
-	elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer)
310
-	{
311
-		$object->setMaxPeriod(GETPOST('nb_gen_max', 'int'));
312
-	}
313
-	// Set auto validate
314
-	elseif ($action == 'setauto_validate' && $user->rights->facture->creer)
315
-	{
316
-		$object->setAutoValidate(GETPOST('auto_validate', 'int'));
260
+        exit;
261
+    }
262
+
263
+
264
+    // Update field
265
+    // Set condition
266
+    if ($action == 'setconditions' && $user->rights->facture->creer)
267
+    {
268
+        $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
269
+    }
270
+    // Set mode
271
+    elseif ($action == 'setmode' && $user->rights->facture->creer)
272
+    {
273
+        $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
274
+    }
275
+    // Set project
276
+    elseif ($action == 'classin' && $user->rights->facture->creer)
277
+    {
278
+        $object->setProject(GETPOST('projectid', 'int'));
279
+    }
280
+    // Set bank account
281
+    elseif ($action == 'setref' && $user->rights->facture->creer)
282
+    {
283
+        //var_dump(GETPOST('ref', 'alpha'));exit;
284
+        $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY');
285
+        if ($result > 0)
286
+        {
287
+            $object->titre = GETPOST('ref', 'alpha');
288
+            $object->ref = $object->titre;
289
+        }
290
+        else dol_print_error($db, $object->error, $object->errors);
291
+    }
292
+    // Set bank account
293
+    elseif ($action == 'setbankaccount' && $user->rights->facture->creer)
294
+    {
295
+        $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
296
+    }
297
+    // Set frequency and unit frequency
298
+    elseif ($action == 'setfrequency' && $user->rights->facture->creer)
299
+    {
300
+        $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha'));
301
+    }
302
+    // Set next date of execution
303
+    elseif ($action == 'setdate_when' && $user->rights->facture->creer)
304
+    {
305
+        $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
306
+        if (!empty($date)) $object->setNextDate($date);
307
+    }
308
+    // Set max period
309
+    elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer)
310
+    {
311
+        $object->setMaxPeriod(GETPOST('nb_gen_max', 'int'));
312
+    }
313
+    // Set auto validate
314
+    elseif ($action == 'setauto_validate' && $user->rights->facture->creer)
315
+    {
316
+        $object->setAutoValidate(GETPOST('auto_validate', 'int'));
317 317
     }
318 318
     // Set generate pdf
319
-	elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer)
320
-	{
321
-		$object->setGeneratepdf(GETPOST('generate_pdf', 'int'));
322
-	}
319
+    elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer)
320
+    {
321
+        $object->setGeneratepdf(GETPOST('generate_pdf', 'int'));
322
+    }
323 323
     // Set model pdf
324
-	elseif ($action == 'setmodelpdf' && $user->rights->facture->creer)
325
-	{
326
-		$object->setModelpdf(GETPOST('modelpdf', 'alpha'));
327
-	}
328
-
329
-	// Set status disabled
330
-	elseif ($action == 'disable' && $user->rights->facture->creer)
331
-	{
332
-		$db->begin();
333
-
334
-		$object->fetch($id);
335
-
336
-		$res = $object->setValueFrom('suspended', 1);
337
-		if ($res <= 0)
338
-		{
339
-			$error++;
340
-		}
341
-
342
-		if (! $error)
343
-		{
344
-			$db->commit();
345
-		}
346
-		else
347
-		{
348
-			$db->rollback();
349
-			setEventMessages($object->error, $object->errors, 'errors');
350
-		}
351
-	}
352
-
353
-	// Set status enabled
354
-	elseif ($action == 'enable' && $user->rights->facture->creer)
355
-	{
356
-		$db->begin();
357
-
358
-		$object->fetch($id);
359
-
360
-		$res = $object->setValueFrom('suspended', 0);
361
-		if ($res <= 0)
362
-		{
363
-			$error++;
364
-		}
365
-
366
-		if (! $error)
367
-		{
368
-			$db->commit();
369
-		}
370
-		else
371
-		{
372
-			$db->rollback();
373
-			setEventMessages($object->error, $object->errors, 'errors');
374
-		}
375
-	}
376
-
377
-	// Delete line
378
-	if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
379
-	{
380
-		$object->fetch($id);
381
-		$object->fetch_thirdparty();
382
-
383
-		$db->begin();
384
-
385
-		$line=new FactureLigneRec($db);
386
-
387
-		// For triggers
388
-		$line->id = $lineid;
389
-
390
-		if ($line->delete($user) > 0)
391
-		{
392
-			$result=$object->update_price(1);
393
-
394
-			if ($result > 0)
395
-			{
396
-				$db->commit();
397
-				$object->fetch($object->id);    // Reload lines
398
-			}
399
-			else
400
-			{
401
-				$db->rollback();
402
-				setEventMessages($db->lasterror(), null, 'errors');
403
-			}
404
-		}
405
-		else
406
-		{
407
-			$db->rollback();
408
-			setEventMessages($line->error, $line->errors, 'errors');
409
-		}
410
-	}
411
-	else if ($action == 'update_extras')
412
-	{
413
-		$object->oldcopy = dol_clone($object);
414
-
415
-		// Fill array 'array_options' with data from update form
416
-		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
417
-		$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none'));
418
-		if ($ret < 0) $error++;
419
-
420
-		if (! $error)
421
-		{
422
-			$result = $object->insertExtraFields('BILLREC_MODIFY');
423
-			if ($result < 0)
424
-			{
425
-				setEventMessages($object->error, $object->errors, 'errors');
426
-				$error++;
427
-			}
428
-		}
429
-	}
430
-
431
-	// Add a new line
432
-	if ($action == 'addline' && $user->rights->facture->creer)
433
-	{
434
-		$langs->load('errors');
435
-		$error = 0;
436
-
437
-		// Set if we used free entry or predefined product
438
-		$predef='';
439
-		$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
440
-		$price_ht = GETPOST('price_ht');
441
-		if (GETPOST('prod_entry_mode') == 'free')
442
-		{
443
-			$idprod=0;
444
-			$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
445
-		}
446
-		else
447
-		{
448
-			$idprod=GETPOST('idprod', 'int');
449
-			$tva_tx = '';
450
-		}
451
-
452
-		$qty = GETPOST('qty' . $predef);
453
-		$remise_percent = GETPOST('remise_percent' . $predef);
454
-
455
-		// Extrafields
456
-		$extrafieldsline = new ExtraFields($db);
457
-		$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
458
-		$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
459
-		// Unset extrafield
460
-		if (is_array($extralabelsline))
461
-		{
462
-			// Get extra fields
463
-			foreach ($extralabelsline as $key => $value) {
464
-				unset($_POST["options_" . $key . $predef]);
465
-			}
466
-		}
467
-
468
-		if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
469
-			setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
470
-			$error ++;
471
-		}
472
-		if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
473
-			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
474
-			$error ++;
475
-		}
476
-		if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) 	// Unit price can be 0 but not ''
477
-		{
478
-			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
479
-			$error ++;
480
-		}
481
-		if ($qty == '') {
482
-			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
483
-			$error ++;
484
-		}
485
-		if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
486
-			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
487
-			$error ++;
488
-		}
489
-		if ($qty < 0) {
490
-			$langs->load("errors");
491
-			setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
492
-			$error ++;
493
-		}
494
-
495
-		if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod)))
496
-		{
497
-		$ret = $object->fetch($id);
498
-		if ($ret < 0) {
499
-			dol_print_error($db, $object->error);
500
-			exit();
501
-		}
502
-		$ret = $object->fetch_thirdparty();
503
-
504
-		// Clean parameters
505
-		$date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
506
-		$date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
507
-		$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
508
-
509
-		// Define special_code for special lines
510
-		$special_code = 0;
511
-		// if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices
512
-
513
-		// Ecrase $pu par celui du produit
514
-		// Ecrase $desc par celui du produit
515
-		// Ecrase $tva_tx par celui du produit
516
-		// Ecrase $base_price_type par celui du produit
517
-		// Replaces $fk_unit with the product's
518
-		if (! empty($idprod))
519
-			{
520
-			$prod = new Product($db);
521
-			$prod->fetch($idprod);
522
-
523
-			$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
524
-
525
-			// Update if prices fields are defined
526
-			$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
527
-			$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
528
-			if (empty($tva_tx)) $tva_npr=0;
529
-
530
-			$pu_ht = $prod->price;
531
-			$pu_ttc = $prod->price_ttc;
532
-			$price_min = $prod->price_min;
533
-			$price_base_type = $prod->price_base_type;
534
-
535
-			// We define price for product
536
-			if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
537
-			{
538
-				$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
539
-				$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
540
-				$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
541
-				$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
542
-				if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))  // using this option is a bug. kept for backward compatibility
543
-				{
544
-					if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
545
-					if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
546
-					if (empty($tva_tx)) $tva_npr=0;
547
-				}
548
-			}
549
-			elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
550
-			{
551
-				include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
552
-
553
-				$prodcustprice = new Productcustomerprice($db);
554
-
555
-				$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
556
-
557
-				$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
558
-				if ($result)
559
-				{
560
-					if (count($prodcustprice->lines) > 0)
561
-					{
562
-						$pu_ht = price($prodcustprice->lines[0]->price);
563
-						$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
564
-						$price_base_type = $prodcustprice->lines[0]->price_base_type;
565
-						$tva_tx = $prodcustprice->lines[0]->tva_tx;
566
-						if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
567
-						$tva_npr = $prodcustprice->lines[0]->recuperableonly;
568
-						if (empty($tva_tx)) $tva_npr=0;
569
-					}
570
-				}
571
-			}
572
-
573
-			$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
574
-			$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
575
-
576
-			// if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
577
-			if (! empty($price_ht))
578
-			{
579
-				$pu_ht = price2num($price_ht, 'MU');
580
-				$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
581
-			}
582
-			// On reevalue prix selon taux tva car taux tva transaction peut etre different
583
-			// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
584
-			elseif ($tmpvat != $tmpprodvat)
585
-			{
586
-				if ($price_base_type != 'HT')
587
-				{
588
-					$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
589
-				}
590
-				else
591
-				{
592
-					$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
593
-				}
594
-			}
595
-
596
-			$desc = '';
597
-
598
-			// Define output language
599
-			if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
600
-			{
601
-				$outputlangs = $langs;
602
-				$newlang = '';
603
-				if (empty($newlang) && GETPOST('lang_id','aZ09'))
604
-					$newlang = GETPOST('lang_id','aZ09');
605
-				if (empty($newlang))
606
-					$newlang = $object->thirdparty->default_lang;
607
-				if (! empty($newlang))
608
-				{
609
-					$outputlangs = new Translate("", $conf);
610
-					$outputlangs->setDefaultLang($newlang);
611
-				}
612
-
613
-				$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
614
-			}
615
-			else
616
-			{
617
-				$desc = $prod->description;
618
-			}
619
-
620
-					$desc = dol_concatdesc($desc, $product_desc);
621
-
622
-			// Add custom code and origin country into description
623
-			if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
624
-			{
625
-				$tmptxt = '(';
626
-				if (! empty($prod->customcode))
627
-					$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
628
-				if (! empty($prod->customcode) && ! empty($prod->country_code))
629
-					$tmptxt .= ' - ';
630
-				if (! empty($prod->country_code))
631
-					$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
632
-				$tmptxt .= ')';
633
-				$desc = dol_concatdesc($desc, $tmptxt);
634
-			}
635
-
636
-			$type = $prod->type;
637
-			$fk_unit = $prod->fk_unit;
638
-		}
639
-		else
640
-		{
641
-			$pu_ht = price2num($price_ht, 'MU');
642
-			$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
643
-			$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
644
-			$tva_tx = str_replace('*', '', $tva_tx);
645
-			if (empty($tva_tx)) $tva_npr=0;
646
-			$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
647
-			$desc = $product_desc;
648
-			$type = GETPOST('type');
649
-			$fk_unit= GETPOST('units', 'alpha');
650
-		}
651
-
652
-		$date_start_fill = GETPOST('date_start_fill','int');
653
-		$date_end_fill = GETPOST('date_end_fill','int');
654
-
655
-		// Margin
656
-		$fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
657
-		$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : '');    // If buying_price is '0', we must keep this value
658
-
659
-		// Local Taxes
660
-		$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
661
-		$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
662
-
663
-		$info_bits = 0;
664
-		if ($tva_npr)
665
-			$info_bits |= 0x01;
666
-
667
-		if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))))
668
-		{
669
-			$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
670
-			setEventMessages($mesg, null, 'errors');
671
-		}
672
-		else
673
-		{
674
-			// Insert line
675
-			$result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill);
676
-
677
-			if ($result > 0)
678
-			{
679
-				/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
324
+    elseif ($action == 'setmodelpdf' && $user->rights->facture->creer)
325
+    {
326
+        $object->setModelpdf(GETPOST('modelpdf', 'alpha'));
327
+    }
328
+
329
+    // Set status disabled
330
+    elseif ($action == 'disable' && $user->rights->facture->creer)
331
+    {
332
+        $db->begin();
333
+
334
+        $object->fetch($id);
335
+
336
+        $res = $object->setValueFrom('suspended', 1);
337
+        if ($res <= 0)
338
+        {
339
+            $error++;
340
+        }
341
+
342
+        if (! $error)
343
+        {
344
+            $db->commit();
345
+        }
346
+        else
347
+        {
348
+            $db->rollback();
349
+            setEventMessages($object->error, $object->errors, 'errors');
350
+        }
351
+    }
352
+
353
+    // Set status enabled
354
+    elseif ($action == 'enable' && $user->rights->facture->creer)
355
+    {
356
+        $db->begin();
357
+
358
+        $object->fetch($id);
359
+
360
+        $res = $object->setValueFrom('suspended', 0);
361
+        if ($res <= 0)
362
+        {
363
+            $error++;
364
+        }
365
+
366
+        if (! $error)
367
+        {
368
+            $db->commit();
369
+        }
370
+        else
371
+        {
372
+            $db->rollback();
373
+            setEventMessages($object->error, $object->errors, 'errors');
374
+        }
375
+    }
376
+
377
+    // Delete line
378
+    if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
379
+    {
380
+        $object->fetch($id);
381
+        $object->fetch_thirdparty();
382
+
383
+        $db->begin();
384
+
385
+        $line=new FactureLigneRec($db);
386
+
387
+        // For triggers
388
+        $line->id = $lineid;
389
+
390
+        if ($line->delete($user) > 0)
391
+        {
392
+            $result=$object->update_price(1);
393
+
394
+            if ($result > 0)
395
+            {
396
+                $db->commit();
397
+                $object->fetch($object->id);    // Reload lines
398
+            }
399
+            else
400
+            {
401
+                $db->rollback();
402
+                setEventMessages($db->lasterror(), null, 'errors');
403
+            }
404
+        }
405
+        else
406
+        {
407
+            $db->rollback();
408
+            setEventMessages($line->error, $line->errors, 'errors');
409
+        }
410
+    }
411
+    else if ($action == 'update_extras')
412
+    {
413
+        $object->oldcopy = dol_clone($object);
414
+
415
+        // Fill array 'array_options' with data from update form
416
+        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
417
+        $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none'));
418
+        if ($ret < 0) $error++;
419
+
420
+        if (! $error)
421
+        {
422
+            $result = $object->insertExtraFields('BILLREC_MODIFY');
423
+            if ($result < 0)
424
+            {
425
+                setEventMessages($object->error, $object->errors, 'errors');
426
+                $error++;
427
+            }
428
+        }
429
+    }
430
+
431
+    // Add a new line
432
+    if ($action == 'addline' && $user->rights->facture->creer)
433
+    {
434
+        $langs->load('errors');
435
+        $error = 0;
436
+
437
+        // Set if we used free entry or predefined product
438
+        $predef='';
439
+        $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
440
+        $price_ht = GETPOST('price_ht');
441
+        if (GETPOST('prod_entry_mode') == 'free')
442
+        {
443
+            $idprod=0;
444
+            $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
445
+        }
446
+        else
447
+        {
448
+            $idprod=GETPOST('idprod', 'int');
449
+            $tva_tx = '';
450
+        }
451
+
452
+        $qty = GETPOST('qty' . $predef);
453
+        $remise_percent = GETPOST('remise_percent' . $predef);
454
+
455
+        // Extrafields
456
+        $extrafieldsline = new ExtraFields($db);
457
+        $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
458
+        $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
459
+        // Unset extrafield
460
+        if (is_array($extralabelsline))
461
+        {
462
+            // Get extra fields
463
+            foreach ($extralabelsline as $key => $value) {
464
+                unset($_POST["options_" . $key . $predef]);
465
+            }
466
+        }
467
+
468
+        if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
469
+            setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
470
+            $error ++;
471
+        }
472
+        if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
473
+            setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
474
+            $error ++;
475
+        }
476
+        if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) 	// Unit price can be 0 but not ''
477
+        {
478
+            setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
479
+            $error ++;
480
+        }
481
+        if ($qty == '') {
482
+            setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
483
+            $error ++;
484
+        }
485
+        if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
486
+            setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
487
+            $error ++;
488
+        }
489
+        if ($qty < 0) {
490
+            $langs->load("errors");
491
+            setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
492
+            $error ++;
493
+        }
494
+
495
+        if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod)))
496
+        {
497
+        $ret = $object->fetch($id);
498
+        if ($ret < 0) {
499
+            dol_print_error($db, $object->error);
500
+            exit();
501
+        }
502
+        $ret = $object->fetch_thirdparty();
503
+
504
+        // Clean parameters
505
+        $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
506
+        $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
507
+        $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
508
+
509
+        // Define special_code for special lines
510
+        $special_code = 0;
511
+        // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices
512
+
513
+        // Ecrase $pu par celui du produit
514
+        // Ecrase $desc par celui du produit
515
+        // Ecrase $tva_tx par celui du produit
516
+        // Ecrase $base_price_type par celui du produit
517
+        // Replaces $fk_unit with the product's
518
+        if (! empty($idprod))
519
+            {
520
+            $prod = new Product($db);
521
+            $prod->fetch($idprod);
522
+
523
+            $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
524
+
525
+            // Update if prices fields are defined
526
+            $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
527
+            $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
528
+            if (empty($tva_tx)) $tva_npr=0;
529
+
530
+            $pu_ht = $prod->price;
531
+            $pu_ttc = $prod->price_ttc;
532
+            $price_min = $prod->price_min;
533
+            $price_base_type = $prod->price_base_type;
534
+
535
+            // We define price for product
536
+            if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
537
+            {
538
+                $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
539
+                $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
540
+                $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
541
+                $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
542
+                if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))  // using this option is a bug. kept for backward compatibility
543
+                {
544
+                    if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
545
+                    if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
546
+                    if (empty($tva_tx)) $tva_npr=0;
547
+                }
548
+            }
549
+            elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
550
+            {
551
+                include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
552
+
553
+                $prodcustprice = new Productcustomerprice($db);
554
+
555
+                $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
556
+
557
+                $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
558
+                if ($result)
559
+                {
560
+                    if (count($prodcustprice->lines) > 0)
561
+                    {
562
+                        $pu_ht = price($prodcustprice->lines[0]->price);
563
+                        $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
564
+                        $price_base_type = $prodcustprice->lines[0]->price_base_type;
565
+                        $tva_tx = $prodcustprice->lines[0]->tva_tx;
566
+                        if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
567
+                        $tva_npr = $prodcustprice->lines[0]->recuperableonly;
568
+                        if (empty($tva_tx)) $tva_npr=0;
569
+                    }
570
+                }
571
+            }
572
+
573
+            $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
574
+            $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
575
+
576
+            // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
577
+            if (! empty($price_ht))
578
+            {
579
+                $pu_ht = price2num($price_ht, 'MU');
580
+                $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
581
+            }
582
+            // On reevalue prix selon taux tva car taux tva transaction peut etre different
583
+            // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
584
+            elseif ($tmpvat != $tmpprodvat)
585
+            {
586
+                if ($price_base_type != 'HT')
587
+                {
588
+                    $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
589
+                }
590
+                else
591
+                {
592
+                    $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
593
+                }
594
+            }
595
+
596
+            $desc = '';
597
+
598
+            // Define output language
599
+            if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
600
+            {
601
+                $outputlangs = $langs;
602
+                $newlang = '';
603
+                if (empty($newlang) && GETPOST('lang_id','aZ09'))
604
+                    $newlang = GETPOST('lang_id','aZ09');
605
+                if (empty($newlang))
606
+                    $newlang = $object->thirdparty->default_lang;
607
+                if (! empty($newlang))
608
+                {
609
+                    $outputlangs = new Translate("", $conf);
610
+                    $outputlangs->setDefaultLang($newlang);
611
+                }
612
+
613
+                $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
614
+            }
615
+            else
616
+            {
617
+                $desc = $prod->description;
618
+            }
619
+
620
+                    $desc = dol_concatdesc($desc, $product_desc);
621
+
622
+            // Add custom code and origin country into description
623
+            if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
624
+            {
625
+                $tmptxt = '(';
626
+                if (! empty($prod->customcode))
627
+                    $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
628
+                if (! empty($prod->customcode) && ! empty($prod->country_code))
629
+                    $tmptxt .= ' - ';
630
+                if (! empty($prod->country_code))
631
+                    $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
632
+                $tmptxt .= ')';
633
+                $desc = dol_concatdesc($desc, $tmptxt);
634
+            }
635
+
636
+            $type = $prod->type;
637
+            $fk_unit = $prod->fk_unit;
638
+        }
639
+        else
640
+        {
641
+            $pu_ht = price2num($price_ht, 'MU');
642
+            $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
643
+            $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
644
+            $tva_tx = str_replace('*', '', $tva_tx);
645
+            if (empty($tva_tx)) $tva_npr=0;
646
+            $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
647
+            $desc = $product_desc;
648
+            $type = GETPOST('type');
649
+            $fk_unit= GETPOST('units', 'alpha');
650
+        }
651
+
652
+        $date_start_fill = GETPOST('date_start_fill','int');
653
+        $date_end_fill = GETPOST('date_end_fill','int');
654
+
655
+        // Margin
656
+        $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
657
+        $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : '');    // If buying_price is '0', we must keep this value
658
+
659
+        // Local Taxes
660
+        $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
661
+        $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
662
+
663
+        $info_bits = 0;
664
+        if ($tva_npr)
665
+            $info_bits |= 0x01;
666
+
667
+        if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))))
668
+        {
669
+            $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
670
+            setEventMessages($mesg, null, 'errors');
671
+        }
672
+        else
673
+        {
674
+            // Insert line
675
+            $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill);
676
+
677
+            if ($result > 0)
678
+            {
679
+                /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
680 680
     			{
681 681
     			    // Define output language
682 682
     			    $outputlangs = $langs;
@@ -693,117 +693,117 @@  discard block
 block discarded – undo
693 693
     			    $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
694 694
     			    if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
695 695
     			}*/
696
-				$object->fetch($object->id);    // Reload lines
697
-
698
-				unset($_POST['prod_entry_mode']);
699
-
700
-				unset($_POST['qty']);
701
-				unset($_POST['type']);
702
-				unset($_POST['remise_percent']);
703
-				unset($_POST['price_ht']);
704
-				unset($_POST['multicurrency_price_ht']);
705
-				unset($_POST['price_ttc']);
706
-				unset($_POST['tva_tx']);
707
-				unset($_POST['product_ref']);
708
-				unset($_POST['product_label']);
709
-				unset($_POST['product_desc']);
710
-				unset($_POST['fournprice']);
711
-				unset($_POST['buying_price']);
712
-				unset($_POST['np_marginRate']);
713
-				unset($_POST['np_markRate']);
714
-				unset($_POST['dp_desc']);
715
-				unset($_POST['idprod']);
716
-				unset($_POST['units']);
717
-
718
-				unset($_POST['date_starthour']);
719
-				unset($_POST['date_startmin']);
720
-				unset($_POST['date_startsec']);
721
-				unset($_POST['date_startday']);
722
-				unset($_POST['date_startmonth']);
723
-				unset($_POST['date_startyear']);
724
-				unset($_POST['date_endhour']);
725
-				unset($_POST['date_endmin']);
726
-				unset($_POST['date_endsec']);
727
-				unset($_POST['date_endday']);
728
-				unset($_POST['date_endmonth']);
729
-				unset($_POST['date_endyear']);
730
-
731
-				unset($_POST['date_start_fill']);
732
-				unset($_POST['date_end_fill']);
733
-
734
-				unset($_POST['situations']);
735
-				unset($_POST['progress']);
736
-			}
737
-			else
738
-			{
739
-				setEventMessages($object->error, $object->errors, 'errors');
740
-			}
741
-
742
-			$action = '';
743
-		}
744
-		}
745
-	}
746
-
747
-	elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha'))
748
-	{
749
-		if (! $object->fetch($id) > 0)	dol_print_error($db);
750
-		$object->fetch_thirdparty();
751
-
752
-		// Clean parameters
753
-		$date_start = '';
754
-		$date_end = '';
755
-		//$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
756
-		//$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
757
-		$description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none'));
758
-		$pu_ht = GETPOST('price_ht');
759
-		$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
760
-		$qty = GETPOST('qty');
761
-		$pu_ht_devise = GETPOST('multicurrency_subprice');
762
-
763
-		// Define info_bits
764
-		$info_bits = 0;
765
-		if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01;
766
-
767
-		// Define vat_rate
768
-		$vat_rate = str_replace('*', '', $vat_rate);
769
-		$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
770
-		$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
771
-
772
-		// Add buying price
773
-		$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
774
-		$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : '');       // If buying_price is '0', we muste keep this value
775
-
776
-		// Extrafields
777
-		$extrafieldsline = new ExtraFields($db);
778
-		$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
779
-		$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
780
-
781
-		$objectline = new FactureLigneRec($db);
782
-		if ($objectline->fetch(GETPOST('lineid')))
783
-		{
784
-			$objectline->array_options=$array_options;
785
-			$result=$objectline->insertExtraFields();
786
-			if ($result < 0)
787
-			{
788
-				setEventMessages($langs->trans('Error').$result, null, 'errors');
789
-			}
790
-		}
791
-
792
-		// Unset extrafield
793
-		if (is_array($extralabelsline))
794
-		{
795
-			// Get extra fields
796
-			foreach ($extralabelsline as $key => $value)
797
-			{
798
-				 unset($_POST["options_" . $key]);
799
-			}
800
-		}
801
-
802
-		// Define special_code for special lines
803
-		$special_code=GETPOST('special_code');
804
-		if (! GETPOST('qty')) $special_code=3;
805
-
806
-		/*$line = new FactureLigne($db);
696
+                $object->fetch($object->id);    // Reload lines
697
+
698
+                unset($_POST['prod_entry_mode']);
699
+
700
+                unset($_POST['qty']);
701
+                unset($_POST['type']);
702
+                unset($_POST['remise_percent']);
703
+                unset($_POST['price_ht']);
704
+                unset($_POST['multicurrency_price_ht']);
705
+                unset($_POST['price_ttc']);
706
+                unset($_POST['tva_tx']);
707
+                unset($_POST['product_ref']);
708
+                unset($_POST['product_label']);
709
+                unset($_POST['product_desc']);
710
+                unset($_POST['fournprice']);
711
+                unset($_POST['buying_price']);
712
+                unset($_POST['np_marginRate']);
713
+                unset($_POST['np_markRate']);
714
+                unset($_POST['dp_desc']);
715
+                unset($_POST['idprod']);
716
+                unset($_POST['units']);
717
+
718
+                unset($_POST['date_starthour']);
719
+                unset($_POST['date_startmin']);
720
+                unset($_POST['date_startsec']);
721
+                unset($_POST['date_startday']);
722
+                unset($_POST['date_startmonth']);
723
+                unset($_POST['date_startyear']);
724
+                unset($_POST['date_endhour']);
725
+                unset($_POST['date_endmin']);
726
+                unset($_POST['date_endsec']);
727
+                unset($_POST['date_endday']);
728
+                unset($_POST['date_endmonth']);
729
+                unset($_POST['date_endyear']);
730
+
731
+                unset($_POST['date_start_fill']);
732
+                unset($_POST['date_end_fill']);
733
+
734
+                unset($_POST['situations']);
735
+                unset($_POST['progress']);
736
+            }
737
+            else
738
+            {
739
+                setEventMessages($object->error, $object->errors, 'errors');
740
+            }
741
+
742
+            $action = '';
743
+        }
744
+        }
745
+    }
746
+
747
+    elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha'))
748
+    {
749
+        if (! $object->fetch($id) > 0)	dol_print_error($db);
750
+        $object->fetch_thirdparty();
751
+
752
+        // Clean parameters
753
+        $date_start = '';
754
+        $date_end = '';
755
+        //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
756
+        //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
757
+        $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none'));
758
+        $pu_ht = GETPOST('price_ht');
759
+        $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
760
+        $qty = GETPOST('qty');
761
+        $pu_ht_devise = GETPOST('multicurrency_subprice');
762
+
763
+        // Define info_bits
764
+        $info_bits = 0;
765
+        if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01;
766
+
767
+        // Define vat_rate
768
+        $vat_rate = str_replace('*', '', $vat_rate);
769
+        $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
770
+        $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
771
+
772
+        // Add buying price
773
+        $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
774
+        $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : '');       // If buying_price is '0', we muste keep this value
775
+
776
+        // Extrafields
777
+        $extrafieldsline = new ExtraFields($db);
778
+        $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
779
+        $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
780
+
781
+        $objectline = new FactureLigneRec($db);
782
+        if ($objectline->fetch(GETPOST('lineid')))
783
+        {
784
+            $objectline->array_options=$array_options;
785
+            $result=$objectline->insertExtraFields();
786
+            if ($result < 0)
787
+            {
788
+                setEventMessages($langs->trans('Error').$result, null, 'errors');
789
+            }
790
+        }
791
+
792
+        // Unset extrafield
793
+        if (is_array($extralabelsline))
794
+        {
795
+            // Get extra fields
796
+            foreach ($extralabelsline as $key => $value)
797
+            {
798
+                    unset($_POST["options_" . $key]);
799
+            }
800
+        }
801
+
802
+        // Define special_code for special lines
803
+        $special_code=GETPOST('special_code');
804
+        if (! GETPOST('qty')) $special_code=3;
805
+
806
+        /*$line = new FactureLigne($db);
807 807
         $line->fetch(GETPOST('lineid'));
808 808
         $percent = $line->get_prev_progress($object->id);
809 809
 
@@ -815,77 +815,77 @@  discard block
 block discarded – undo
815 815
                 $result = -1;
816 816
         }*/
817 817
 
818
-		// Check minimum price
819
-		$productid = GETPOST('productid', 'int');
820
-		if (! empty($productid))
821
-		{
822
-			$product = new Product($db);
823
-			$product->fetch($productid);
824
-
825
-			$type = $product->type;
826
-
827
-			$price_min = $product->price_min;
828
-			if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
829
-				$price_min = $product->multiprices_min[$object->thirdparty->price_level];
830
-
831
-			$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
832
-
833
-			// Check price is not lower than minimum (check is done only for standard or replacement invoices)
834
-			if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))))
835
-			{
836
-				setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
837
-				$error ++;
838
-			}
839
-		} else {
840
-			$type = GETPOST('type');
841
-			$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
842
-
843
-				// Check parameters
844
-				if (GETPOST('type') < 0) {
845
-					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
846
-					$error ++;
847
-				}
848
-			}
849
-		if ($qty < 0) {
850
-			$langs->load("errors");
851
-			setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
852
-			$error ++;
853
-		}
854
-
855
-		$date_start_fill = GETPOST('date_start_fill','int');
856
-		$date_end_fill = GETPOST('date_end_fill','int');
857
-
858
-		// Update line
859
-		if (! $error)
860
-		{
861
-			$result = $object->updateline(
862
-				GETPOST('lineid'),
863
-				$description,
864
-				$pu_ht,
865
-				$qty,
866
-				$vat_rate,
867
-				$localtax1_rate,
868
-				$localtax1_rate,
869
-				GETPOST('productid'),
870
-				GETPOST('remise_percent'),
871
-				'HT',
872
-				$info_bits,
873
-				0,
874
-				0,
875
-				$type,
876
-				0,
877
-				$special_code,
878
-				$label,
879
-				GETPOST('units'),
880
-				$pu_ht_devise,
881
-				0,
882
-				$date_start_fill,
883
-				$date_end_fill
884
-			);
885
-
886
-			if ($result >= 0)
887
-			{
888
-					/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
818
+        // Check minimum price
819
+        $productid = GETPOST('productid', 'int');
820
+        if (! empty($productid))
821
+        {
822
+            $product = new Product($db);
823
+            $product->fetch($productid);
824
+
825
+            $type = $product->type;
826
+
827
+            $price_min = $product->price_min;
828
+            if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
829
+                $price_min = $product->multiprices_min[$object->thirdparty->price_level];
830
+
831
+            $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
832
+
833
+            // Check price is not lower than minimum (check is done only for standard or replacement invoices)
834
+            if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))))
835
+            {
836
+                setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
837
+                $error ++;
838
+            }
839
+        } else {
840
+            $type = GETPOST('type');
841
+            $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
842
+
843
+                // Check parameters
844
+                if (GETPOST('type') < 0) {
845
+                    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
846
+                    $error ++;
847
+                }
848
+            }
849
+        if ($qty < 0) {
850
+            $langs->load("errors");
851
+            setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
852
+            $error ++;
853
+        }
854
+
855
+        $date_start_fill = GETPOST('date_start_fill','int');
856
+        $date_end_fill = GETPOST('date_end_fill','int');
857
+
858
+        // Update line
859
+        if (! $error)
860
+        {
861
+            $result = $object->updateline(
862
+                GETPOST('lineid'),
863
+                $description,
864
+                $pu_ht,
865
+                $qty,
866
+                $vat_rate,
867
+                $localtax1_rate,
868
+                $localtax1_rate,
869
+                GETPOST('productid'),
870
+                GETPOST('remise_percent'),
871
+                'HT',
872
+                $info_bits,
873
+                0,
874
+                0,
875
+                $type,
876
+                0,
877
+                $special_code,
878
+                $label,
879
+                GETPOST('units'),
880
+                $pu_ht_devise,
881
+                0,
882
+                $date_start_fill,
883
+                $date_end_fill
884
+            );
885
+
886
+            if ($result >= 0)
887
+            {
888
+                    /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
889 889
                         // Define output language
890 890
                         $outputlangs = $langs;
891 891
                         $newlang = '';
@@ -902,50 +902,50 @@  discard block
 block discarded – undo
902 902
                                 $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
903 903
                     }*/
904 904
 
905
-				$object->fetch($object->id);    // Reload lines
906
-
907
-				unset($_POST['qty']);
908
-				unset($_POST['type']);
909
-				unset($_POST['productid']);
910
-				unset($_POST['remise_percent']);
911
-				unset($_POST['price_ht']);
912
-				unset($_POST['multicurrency_price_ht']);
913
-				unset($_POST['price_ttc']);
914
-				unset($_POST['tva_tx']);
915
-				unset($_POST['product_ref']);
916
-				unset($_POST['product_label']);
917
-				unset($_POST['product_desc']);
918
-				unset($_POST['fournprice']);
919
-				unset($_POST['buying_price']);
920
-				unset($_POST['np_marginRate']);
921
-				unset($_POST['np_markRate']);
922
-
923
-				unset($_POST['dp_desc']);
924
-				unset($_POST['idprod']);
925
-				unset($_POST['units']);
926
-
927
-				unset($_POST['date_starthour']);
928
-				unset($_POST['date_startmin']);
929
-				unset($_POST['date_startsec']);
930
-				unset($_POST['date_startday']);
931
-				unset($_POST['date_startmonth']);
932
-				unset($_POST['date_startyear']);
933
-				unset($_POST['date_endhour']);
934
-				unset($_POST['date_endmin']);
935
-				unset($_POST['date_endsec']);
936
-				unset($_POST['date_endday']);
937
-				unset($_POST['date_endmonth']);
938
-				unset($_POST['date_endyear']);
939
-
940
-				unset($_POST['situations']);
941
-				unset($_POST['progress']);
942
-			}
943
-			else
944
-			{
945
-				setEventMessages($object->error, $object->errors, 'errors');
946
-			}
947
-		}
948
-	}
905
+                $object->fetch($object->id);    // Reload lines
906
+
907
+                unset($_POST['qty']);
908
+                unset($_POST['type']);
909
+                unset($_POST['productid']);
910
+                unset($_POST['remise_percent']);
911
+                unset($_POST['price_ht']);
912
+                unset($_POST['multicurrency_price_ht']);
913
+                unset($_POST['price_ttc']);
914
+                unset($_POST['tva_tx']);
915
+                unset($_POST['product_ref']);
916
+                unset($_POST['product_label']);
917
+                unset($_POST['product_desc']);
918
+                unset($_POST['fournprice']);
919
+                unset($_POST['buying_price']);
920
+                unset($_POST['np_marginRate']);
921
+                unset($_POST['np_markRate']);
922
+
923
+                unset($_POST['dp_desc']);
924
+                unset($_POST['idprod']);
925
+                unset($_POST['units']);
926
+
927
+                unset($_POST['date_starthour']);
928
+                unset($_POST['date_startmin']);
929
+                unset($_POST['date_startsec']);
930
+                unset($_POST['date_startday']);
931
+                unset($_POST['date_startmonth']);
932
+                unset($_POST['date_startyear']);
933
+                unset($_POST['date_endhour']);
934
+                unset($_POST['date_endmin']);
935
+                unset($_POST['date_endsec']);
936
+                unset($_POST['date_endday']);
937
+                unset($_POST['date_endmonth']);
938
+                unset($_POST['date_endyear']);
939
+
940
+                unset($_POST['situations']);
941
+                unset($_POST['progress']);
942
+            }
943
+            else
944
+            {
945
+                setEventMessages($object->error, $object->errors, 'errors');
946
+            }
947
+        }
948
+    }
949 949
 }
950 950
 
951 951
 
@@ -971,119 +971,119 @@  discard block
 block discarded – undo
971 971
  */
972 972
 if ($action == 'create')
973 973
 {
974
-	print load_fiche_titre($langs->trans("CreateRepeatableInvoice"),'','title_accountancy.png');
975
-
976
-	$object = new Facture($db);   // Source invoice
977
-	$product_static = new Product($db);
978
-
979
-	if ($object->fetch($id, $ref) > 0)
980
-	{
981
-		$result = $object->getLinesArray();
982
-
983
-		print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
984
-		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
985
-		print '<input type="hidden" name="action" value="add">';
986
-		print '<input type="hidden" name="facid" value="'.$object->id.'">';
987
-
988
-		dol_fiche_head(null, '', '', 0);
989
-
990
-		$rowspan=4;
991
-		if (! empty($conf->projet->enabled)) $rowspan++;
992
-		if ($object->fk_account > 0) $rowspan++;
993
-
994
-		print '<table class="border" width="100%">';
995
-
996
-		$object->fetch_thirdparty();
997
-
998
-		// Title
999
-		print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>';
1000
-		print '<input class="flat quatrevingtpercent" type="text" name="titre" value="'.$_POST["titre"].'">';
1001
-		print '</td></tr>';
1002
-
1003
-		// Third party
1004
-		print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>';
1005
-		print '</tr>';
1006
-
1007
-		$note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public;
1008
-		$note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private;
1009
-
1010
-		// Help of substitution key
1011
-		$substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
1012
-
1013
-		$substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')';
1014
-		$substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')';
1015
-		$substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')';
1016
-		$substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')';
1017
-		$substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')';
1018
-		$substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')';
1019
-		$substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')';
1020
-		$substitutionarray['__INVOICE_YEAR__'] =  $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')';
1021
-		$substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')';
1022
-		// Only on template invoices
1023
-		$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')';
1024
-		$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')';
1025
-
1026
-		$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
1027
-		foreach($substitutionarray as $key => $val)
1028
-		{
1029
-			$htmltext.=$key.' = '.$langs->trans($val).'<br>';
1030
-		}
1031
-		$htmltext.='</i>';
1032
-
1033
-		// Public note
1034
-		print '<tr>';
1035
-		print '<td class="tdtop">';
1036
-		print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
1037
-		print '</td>';
1038
-		print '<td>';
1039
-		$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
1040
-		print $doleditor->Create(1);
1041
-
1042
-		// Private note
1043
-		if (empty($user->societe_id))
1044
-		{
1045
-			print '<tr>';
1046
-			print '<td class="tdtop">';
1047
-			print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
1048
-			print '</td>';
1049
-			print '<td>';
1050
-			$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
1051
-			print $doleditor->Create(1);
1052
-			// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
1053
-			print '</td></tr>';
1054
-		}
1055
-
1056
-		// Author
1057
-		print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
1058
-
1059
-		// Payment term
1060
-		print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
1061
-		$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
1062
-		print "</td></tr>";
1063
-
1064
-		// Payment mode
1065
-		print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
1066
-		$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1);
1067
-		print "</td></tr>";
1068
-
1069
-		// Project
1070
-		if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0)
1071
-		{
1072
-			$projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
1073
-			$langs->load('projects');
1074
-			print '<tr><td>' . $langs->trans('Project') . '</td><td>';
1075
-			$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
974
+    print load_fiche_titre($langs->trans("CreateRepeatableInvoice"),'','title_accountancy.png');
975
+
976
+    $object = new Facture($db);   // Source invoice
977
+    $product_static = new Product($db);
978
+
979
+    if ($object->fetch($id, $ref) > 0)
980
+    {
981
+        $result = $object->getLinesArray();
982
+
983
+        print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
984
+        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
985
+        print '<input type="hidden" name="action" value="add">';
986
+        print '<input type="hidden" name="facid" value="'.$object->id.'">';
987
+
988
+        dol_fiche_head(null, '', '', 0);
989
+
990
+        $rowspan=4;
991
+        if (! empty($conf->projet->enabled)) $rowspan++;
992
+        if ($object->fk_account > 0) $rowspan++;
993
+
994
+        print '<table class="border" width="100%">';
995
+
996
+        $object->fetch_thirdparty();
997
+
998
+        // Title
999
+        print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>';
1000
+        print '<input class="flat quatrevingtpercent" type="text" name="titre" value="'.$_POST["titre"].'">';
1001
+        print '</td></tr>';
1002
+
1003
+        // Third party
1004
+        print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>';
1005
+        print '</tr>';
1006
+
1007
+        $note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public;
1008
+        $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private;
1009
+
1010
+        // Help of substitution key
1011
+        $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
1012
+
1013
+        $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')';
1014
+        $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')';
1015
+        $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')';
1016
+        $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')';
1017
+        $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')';
1018
+        $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')';
1019
+        $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')';
1020
+        $substitutionarray['__INVOICE_YEAR__'] =  $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')';
1021
+        $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')';
1022
+        // Only on template invoices
1023
+        $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')';
1024
+        $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')';
1025
+
1026
+        $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
1027
+        foreach($substitutionarray as $key => $val)
1028
+        {
1029
+            $htmltext.=$key.' = '.$langs->trans($val).'<br>';
1030
+        }
1031
+        $htmltext.='</i>';
1032
+
1033
+        // Public note
1034
+        print '<tr>';
1035
+        print '<td class="tdtop">';
1036
+        print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
1037
+        print '</td>';
1038
+        print '<td>';
1039
+        $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
1040
+        print $doleditor->Create(1);
1041
+
1042
+        // Private note
1043
+        if (empty($user->societe_id))
1044
+        {
1045
+            print '<tr>';
1046
+            print '<td class="tdtop">';
1047
+            print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
1048
+            print '</td>';
1049
+            print '<td>';
1050
+            $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
1051
+            print $doleditor->Create(1);
1052
+            // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
1053
+            print '</td></tr>';
1054
+        }
1055
+
1056
+        // Author
1057
+        print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
1058
+
1059
+        // Payment term
1060
+        print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
1061
+        $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
1062
+        print "</td></tr>";
1063
+
1064
+        // Payment mode
1065
+        print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
1066
+        $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1);
1067
+        print "</td></tr>";
1068
+
1069
+        // Project
1070
+        if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0)
1071
+        {
1072
+            $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
1073
+            $langs->load('projects');
1074
+            print '<tr><td>' . $langs->trans('Project') . '</td><td>';
1075
+            $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
1076 1076
             print ' &nbsp; <a href="' . BASE_URI . '?controller=projet&method=card&socid=' . $object->thirdparty->id . '&action=create&status=1&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create&socid=' . $object->thirdparty->id . (!empty($id) ? '&id=' . $id : '')) . '">' . $langs->trans("AddProject") . '</a>';
1077
-			print '</td></tr>';
1078
-		}
1077
+            print '</td></tr>';
1078
+        }
1079 1079
 
1080
-		// Bank account
1081
-		if ($object->fk_account > 0)
1082
-		{
1083
-			print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
1084
-			$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
1085
-			print "</td></tr>";
1086
-		}
1080
+        // Bank account
1081
+        if ($object->fk_account > 0)
1082
+        {
1083
+            print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
1084
+            $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
1085
+            print "</td></tr>";
1086
+        }
1087 1087
 
1088 1088
         // Model pdf
1089 1089
         print "<tr><td>".$langs->trans('Model')."</td><td>";
@@ -1092,323 +1092,323 @@  discard block
 block discarded – undo
1092 1092
         print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
1093 1093
         print "</td></tr>";
1094 1094
 
1095
-		print "</table>";
1095
+        print "</table>";
1096 1096
 
1097
-		dol_fiche_end();
1097
+        dol_fiche_end();
1098 1098
 
1099 1099
 
1100
-		// Autogeneration
1101
-		$title = $langs->trans("Recurrence");
1102
-		print load_fiche_titre('<span class="fa fa-calendar"></span> '.$title, '', '');
1100
+        // Autogeneration
1101
+        $title = $langs->trans("Recurrence");
1102
+        print load_fiche_titre('<span class="fa fa-calendar"></span> '.$title, '', '');
1103 1103
 
1104
-		dol_fiche_head(null, '', '', 0);
1104
+        dol_fiche_head(null, '', '', 0);
1105 1105
 
1106
-		print '<table class="border" width="100%">';
1106
+        print '<table class="border" width="100%">';
1107 1107
 
1108
-		// Frequency + unit
1109
-		print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
1110
-		print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
1111
-		print "</td></tr>";
1108
+        // Frequency + unit
1109
+        print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
1110
+        print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
1111
+        print "</td></tr>";
1112 1112
 
1113
-		// Date next run
1114
-		print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>";
1115
-		$date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
1116
-		print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1);
1117
-		print "</td></tr>";
1113
+        // Date next run
1114
+        print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>";
1115
+        $date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
1116
+        print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1);
1117
+        print "</td></tr>";
1118 1118
 
1119
-		// Number max of generation
1120
-		print "<tr><td>".$langs->trans("MaxPeriodNumber")."</td><td>";
1121
-		print '<input type="text" name="nb_gen_max" value="'.GETPOST('nb_gen_max').'" size="5" />';
1122
-		print "</td></tr>";
1119
+        // Number max of generation
1120
+        print "<tr><td>".$langs->trans("MaxPeriodNumber")."</td><td>";
1121
+        print '<input type="text" name="nb_gen_max" value="'.GETPOST('nb_gen_max').'" size="5" />';
1122
+        print "</td></tr>";
1123 1123
 
1124
-		// Auto validate the invoice
1125
-		print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>";
1126
-		$select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated'));
1127
-		print $form->selectarray('auto_validate', $select, GETPOST('auto_validate'));
1128
-		print "</td></tr>";
1124
+        // Auto validate the invoice
1125
+        print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>";
1126
+        $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated'));
1127
+        print $form->selectarray('auto_validate', $select, GETPOST('auto_validate'));
1128
+        print "</td></tr>";
1129 1129
 
1130
-		// Auto generate document
1131
-		if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION))
1132
-		{
1133
-			print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>";
1134
-			$select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc'));
1135
-			print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf'));
1136
-			print "</td></tr>";
1137
-		}
1138
-		else
1139
-		{
1140
-			print '<input type="hidden" name="generate_pdf" value="1">';
1141
-		}
1130
+        // Auto generate document
1131
+        if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION))
1132
+        {
1133
+            print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>";
1134
+            $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc'));
1135
+            print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf'));
1136
+            print "</td></tr>";
1137
+        }
1138
+        else
1139
+        {
1140
+            print '<input type="hidden" name="generate_pdf" value="1">';
1141
+        }
1142 1142
 
1143
-		print "</table>";
1143
+        print "</table>";
1144 1144
 
1145
-		dol_fiche_end();
1145
+        dol_fiche_end();
1146 1146
 
1147 1147
 
1148
-		$title = $langs->trans("ProductsAndServices");
1149
-		if (empty($conf->service->enabled))
1150
-			$title = $langs->trans("Products");
1151
-		else if (empty($conf->product->enabled))
1152
-			$title = $langs->trans("Services");
1148
+        $title = $langs->trans("ProductsAndServices");
1149
+        if (empty($conf->service->enabled))
1150
+            $title = $langs->trans("Products");
1151
+        else if (empty($conf->product->enabled))
1152
+            $title = $langs->trans("Services");
1153 1153
 
1154
-		print load_fiche_titre($title, '', '');
1154
+        print load_fiche_titre($title, '', '');
1155 1155
 
1156
-		/*
1156
+        /*
1157 1157
 		 * Invoice lines
1158 1158
 		 */
1159
-		print '<div class="div-table-responsive-no-min">';
1160
-		print '<table id="tablelines" class="noborder noshadow" width="100%">';
1161
-		// Show object lines
1162
-		if (! empty($object->lines))
1163
-		{
1164
-			$disableedit=1;
1165
-			$disablemove=1;
1166
-			$disableremove=1;
1167
-			$object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0);      // No date selector for template invoice
1168
-		}
1169
-
1170
-		print "</table>\n";
1171
-		print '<div>';
1172
-
1173
-		print '</td></tr>';
1174
-
1175
-		if ($flag_price_may_change)
1176
-		{
1177
-			print '<tr><td colspan="3" align="left">';
1178
-			print '<select name="usenewprice" class="flat">';
1179
-			print '<option value="0">'.$langs->trans("AlwaysUseFixedPrice").'</option>';
1180
-			print '<option value="1" disabled>'.$langs->trans("AlwaysUseNewPrice").'</option>';
1181
-			print '</select>';
1182
-			print '</td></tr>';
1183
-		}
1184
-		print "</table>\n";
1185
-
1186
-		print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">';
1187
-		print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1188
-		print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1189
-		print '</div>';
1190
-		print "</form>\n";
1191
-	}
1192
-	else
1193
-	{
1194
-		dol_print_error('',"Error, no invoice ".$object->id);
1195
-	}
1159
+        print '<div class="div-table-responsive-no-min">';
1160
+        print '<table id="tablelines" class="noborder noshadow" width="100%">';
1161
+        // Show object lines
1162
+        if (! empty($object->lines))
1163
+        {
1164
+            $disableedit=1;
1165
+            $disablemove=1;
1166
+            $disableremove=1;
1167
+            $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0);      // No date selector for template invoice
1168
+        }
1169
+
1170
+        print "</table>\n";
1171
+        print '<div>';
1172
+
1173
+        print '</td></tr>';
1174
+
1175
+        if ($flag_price_may_change)
1176
+        {
1177
+            print '<tr><td colspan="3" align="left">';
1178
+            print '<select name="usenewprice" class="flat">';
1179
+            print '<option value="0">'.$langs->trans("AlwaysUseFixedPrice").'</option>';
1180
+            print '<option value="1" disabled>'.$langs->trans("AlwaysUseNewPrice").'</option>';
1181
+            print '</select>';
1182
+            print '</td></tr>';
1183
+        }
1184
+        print "</table>\n";
1185
+
1186
+        print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">';
1187
+        print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1188
+        print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1189
+        print '</div>';
1190
+        print "</form>\n";
1191
+    }
1192
+    else
1193
+    {
1194
+        dol_print_error('',"Error, no invoice ".$object->id);
1195
+    }
1196 1196
 }
1197 1197
 else
1198 1198
 {
1199
-	/*
1199
+    /*
1200 1200
 	 * View mode
1201 1201
 	 */
1202
-	if ($object->id > 0)
1203
-	{
1204
-		$object->fetch_thirdparty();
1202
+    if ($object->id > 0)
1203
+    {
1204
+        $object->fetch_thirdparty();
1205 1205
 
1206
-		// Confirmation de la suppression d'une ligne produit
1207
-		if ($action == 'ask_deleteline') {
1208
-			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
1209
-		}
1206
+        // Confirmation de la suppression d'une ligne produit
1207
+        if ($action == 'ask_deleteline') {
1208
+            $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
1209
+        }
1210 1210
 
1211
-		// Confirm delete of repeatable invoice
1212
-		if ($action == 'ask_deleteinvoice') {
1213
-			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1);
1214
-		}
1211
+        // Confirm delete of repeatable invoice
1212
+        if ($action == 'ask_deleteinvoice') {
1213
+            $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1);
1214
+        }
1215 1215
 
1216
-		print $formconfirm;
1216
+        print $formconfirm;
1217 1217
 
1218
-		$author = new User($db);
1219
-		$author->fetch($object->user_author);
1218
+        $author = new User($db);
1219
+        $author->fetch($object->user_author);
1220 1220
 
1221
-		$head=invoice_rec_prepare_head($object);
1221
+        $head=invoice_rec_prepare_head($object);
1222 1222
 
1223
-		dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill');	// Add a div
1223
+        dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill');	// Add a div
1224 1224
 
1225
-		// Recurring invoice content
1225
+        // Recurring invoice content
1226 1226
 
1227 1227
         $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=invoicetemplate_list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
1228 1228
 
1229
-		$morehtmlref='';
1230
-		if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
1231
-		else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string');
1232
-
1233
-		$morehtmlref.='<div class="refidno">';
1234
-		// Ref customer
1235
-		//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1);
1236
-		//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1);
1237
-		// Thirdparty
1238
-		$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
1239
-		// Project
1240
-		if (! empty($conf->projet->enabled))
1241
-		{
1242
-			$langs->load("projects");
1243
-			$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
1244
-			if ($user->rights->facture->creer)
1245
-			{
1246
-				if ($action != 'classify')
1247
-					$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
1248
-					if ($action == 'classify') {
1249
-						//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
1250
-						$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1251
-						$morehtmlref.='<input type="hidden" name="action" value="classin">';
1252
-						$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1253
-						$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
1254
-						$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
1255
-						$morehtmlref.='</form>';
1256
-					} else {
1257
-						$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
1258
-					}
1259
-			} else {
1260
-				if (! empty($object->fk_project)) {
1261
-					$proj = new Project($db);
1262
-					$proj->fetch($object->fk_project);
1229
+        $morehtmlref='';
1230
+        if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
1231
+        else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string');
1232
+
1233
+        $morehtmlref.='<div class="refidno">';
1234
+        // Ref customer
1235
+        //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1);
1236
+        //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1);
1237
+        // Thirdparty
1238
+        $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
1239
+        // Project
1240
+        if (! empty($conf->projet->enabled))
1241
+        {
1242
+            $langs->load("projects");
1243
+            $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
1244
+            if ($user->rights->facture->creer)
1245
+            {
1246
+                if ($action != 'classify')
1247
+                    $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
1248
+                    if ($action == 'classify') {
1249
+                        //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
1250
+                        $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1251
+                        $morehtmlref.='<input type="hidden" name="action" value="classin">';
1252
+                        $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1253
+                        $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
1254
+                        $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
1255
+                        $morehtmlref.='</form>';
1256
+                    } else {
1257
+                        $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
1258
+                    }
1259
+            } else {
1260
+                if (! empty($object->fk_project)) {
1261
+                    $proj = new Project($db);
1262
+                    $proj->fetch($object->fk_project);
1263 1263
                     $morehtmlref .= '<a href="' . BASE_URI . '&controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
1264
-					$morehtmlref.=$proj->ref;
1265
-					$morehtmlref.='</a>';
1266
-				} else {
1267
-					$morehtmlref.='';
1268
-				}
1269
-			}
1270
-		}
1271
-		$morehtmlref.='</div>';
1272
-
1273
-		dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright);
1274
-
1275
-		print '<div class="fichecenter">';
1276
-		print '<div class="fichehalfleft">';
1277
-		print '<div class="underbanner clearboth"></div>';
1278
-
1279
-		print '<table class="border" width="100%">';
1280
-
1281
-		print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>'.$author->getFullName($langs)."</td></tr>";
1282
-
1283
-		print '<tr><td>'.$langs->trans("AmountHT").'</td>';
1284
-		print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>';
1285
-		print '</tr>';
1286
-
1287
-		print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>';
1288
-		print '</tr>';
1289
-
1290
-		// Amount Local Taxes
1291
-		if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) 	// Localtax1
1292
-		{
1293
-			print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
1294
-			print '<td class="nowrap">' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
1295
-		}
1296
-		if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) 	// Localtax2
1297
-		{
1298
-			print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
1299
-			print '<td class=nowrap">' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
1300
-		}
1301
-
1302
-		print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>';
1303
-		print '</tr>';
1304
-
1305
-
1306
-		// Payment term
1307
-		print '<tr><td>';
1308
-		print '<table class="nobordernopadding" width="100%"><tr><td>';
1309
-		print $langs->trans('PaymentConditionsShort');
1310
-		print '</td>';
1311
-		if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer)
1312
-			print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>';
1313
-		print '</tr></table>';
1314
-		print '</td><td>';
1315
-		if ($object->type != Facture::TYPE_CREDIT_NOTE)
1316
-		{
1317
-			if ($action == 'editconditions')
1318
-			{
1319
-				$form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id');
1320
-			}
1321
-			else
1322
-			{
1323
-				$form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none');
1324
-			}
1325
-		} else {
1326
-			print '&nbsp;';
1327
-		}
1328
-		print '</td></tr>';
1329
-
1330
-		// Payment mode
1331
-		print '<tr><td>';
1332
-		print '<table class="nobordernopadding" width="100%"><tr><td>';
1333
-		print $langs->trans('PaymentMode');
1334
-		print '</td>';
1335
-		if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer)
1336
-			print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
1337
-		print '</tr></table>';
1338
-		print '</td><td>';
1339
-		if ($action == 'editmode')
1340
-		{
1341
-			$form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT');
1342
-		}
1343
-		else
1344
-		{
1345
-			$form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT');
1346
-		}
1347
-		print '</td></tr>';
1348
-
1349
-		// Help of substitution key
1350
-		$dateexample=dol_now();
1351
-		if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when;
1352
-
1353
-		$substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
1354
-
1355
-		$substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')';
1356
-		$substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')';
1357
-		$substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')';
1358
-		$substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')';
1359
-		$substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')';
1360
-		$substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')';
1361
-		$substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')';
1362
-		$substitutionarray['__INVOICE_YEAR__'] =  $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')';
1363
-		$substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')';
1364
-		// Only on template invoices
1365
-		$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')';
1366
-		$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency),'dayhour').')';
1367
-
1368
-		$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
1369
-		foreach($substitutionarray as $key => $val)
1370
-		{
1371
-			$htmltext.=$key.' = '.$langs->trans($val).'<br>';
1372
-		}
1373
-		$htmltext.='</i>';
1374
-
1375
-		// Note public
1376
-		print '<tr><td>';
1377
-		print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer);
1378
-		print '</td><td class="wordbreak">';
1379
-		print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
1380
-		print '</td>';
1381
-		print '</tr>';
1382
-
1383
-		// Note private
1384
-		print '<tr><td>';
1385
-		print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
1386
-		print '</td><td class="wordbreak">';
1387
-		print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
1388
-		print '</td>';
1389
-		print '</tr>';
1390
-
1391
-		// Bank Account
1392
-		$langs->load('banks');
1393
-
1394
-		print '<tr><td class="nowrap">';
1395
-		print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1396
-		print $langs->trans('RIB');
1397
-		print '<td>';
1398
-		if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon))
1399
-			print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
1400
-		print '</tr></table>';
1401
-		print '</td><td>';
1402
-		if ($action == 'editbankaccount')
1403
-		{
1404
-			$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
1405
-		}
1406
-		else
1407
-		{
1408
-			$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
1409
-		}
1410
-		print "</td>";
1411
-		print '</tr>';
1264
+                    $morehtmlref.=$proj->ref;
1265
+                    $morehtmlref.='</a>';
1266
+                } else {
1267
+                    $morehtmlref.='';
1268
+                }
1269
+            }
1270
+        }
1271
+        $morehtmlref.='</div>';
1272
+
1273
+        dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright);
1274
+
1275
+        print '<div class="fichecenter">';
1276
+        print '<div class="fichehalfleft">';
1277
+        print '<div class="underbanner clearboth"></div>';
1278
+
1279
+        print '<table class="border" width="100%">';
1280
+
1281
+        print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>'.$author->getFullName($langs)."</td></tr>";
1282
+
1283
+        print '<tr><td>'.$langs->trans("AmountHT").'</td>';
1284
+        print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>';
1285
+        print '</tr>';
1286
+
1287
+        print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>';
1288
+        print '</tr>';
1289
+
1290
+        // Amount Local Taxes
1291
+        if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) 	// Localtax1
1292
+        {
1293
+            print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
1294
+            print '<td class="nowrap">' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
1295
+        }
1296
+        if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) 	// Localtax2
1297
+        {
1298
+            print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
1299
+            print '<td class=nowrap">' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
1300
+        }
1301
+
1302
+        print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>';
1303
+        print '</tr>';
1304
+
1305
+
1306
+        // Payment term
1307
+        print '<tr><td>';
1308
+        print '<table class="nobordernopadding" width="100%"><tr><td>';
1309
+        print $langs->trans('PaymentConditionsShort');
1310
+        print '</td>';
1311
+        if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer)
1312
+            print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>';
1313
+        print '</tr></table>';
1314
+        print '</td><td>';
1315
+        if ($object->type != Facture::TYPE_CREDIT_NOTE)
1316
+        {
1317
+            if ($action == 'editconditions')
1318
+            {
1319
+                $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id');
1320
+            }
1321
+            else
1322
+            {
1323
+                $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none');
1324
+            }
1325
+        } else {
1326
+            print '&nbsp;';
1327
+        }
1328
+        print '</td></tr>';
1329
+
1330
+        // Payment mode
1331
+        print '<tr><td>';
1332
+        print '<table class="nobordernopadding" width="100%"><tr><td>';
1333
+        print $langs->trans('PaymentMode');
1334
+        print '</td>';
1335
+        if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer)
1336
+            print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
1337
+        print '</tr></table>';
1338
+        print '</td><td>';
1339
+        if ($action == 'editmode')
1340
+        {
1341
+            $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT');
1342
+        }
1343
+        else
1344
+        {
1345
+            $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT');
1346
+        }
1347
+        print '</td></tr>';
1348
+
1349
+        // Help of substitution key
1350
+        $dateexample=dol_now();
1351
+        if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when;
1352
+
1353
+        $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
1354
+
1355
+        $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')';
1356
+        $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')';
1357
+        $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')';
1358
+        $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')';
1359
+        $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')';
1360
+        $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')';
1361
+        $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')';
1362
+        $substitutionarray['__INVOICE_YEAR__'] =  $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')';
1363
+        $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')';
1364
+        // Only on template invoices
1365
+        $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')';
1366
+        $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency),'dayhour').')';
1367
+
1368
+        $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
1369
+        foreach($substitutionarray as $key => $val)
1370
+        {
1371
+            $htmltext.=$key.' = '.$langs->trans($val).'<br>';
1372
+        }
1373
+        $htmltext.='</i>';
1374
+
1375
+        // Note public
1376
+        print '<tr><td>';
1377
+        print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer);
1378
+        print '</td><td class="wordbreak">';
1379
+        print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
1380
+        print '</td>';
1381
+        print '</tr>';
1382
+
1383
+        // Note private
1384
+        print '<tr><td>';
1385
+        print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
1386
+        print '</td><td class="wordbreak">';
1387
+        print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
1388
+        print '</td>';
1389
+        print '</tr>';
1390
+
1391
+        // Bank Account
1392
+        $langs->load('banks');
1393
+
1394
+        print '<tr><td class="nowrap">';
1395
+        print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1396
+        print $langs->trans('RIB');
1397
+        print '<td>';
1398
+        if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon))
1399
+            print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
1400
+        print '</tr></table>';
1401
+        print '</td><td>';
1402
+        if ($action == 'editbankaccount')
1403
+        {
1404
+            $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
1405
+        }
1406
+        else
1407
+        {
1408
+            $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
1409
+        }
1410
+        print "</td>";
1411
+        print '</tr>';
1412 1412
 
1413 1413
         // Model pdf
1414 1414
         $langs->load('banks');
@@ -1439,298 +1439,298 @@  discard block
 block discarded – undo
1439 1439
         print "</td>";
1440 1440
         print '</tr>';
1441 1441
 
1442
-		// Other attributes
1443
-		$cols = 2;
1444
-		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
1442
+        // Other attributes
1443
+        $cols = 2;
1444
+        include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
1445 1445
 
1446
-		print '</table>';
1446
+        print '</table>';
1447 1447
 
1448
-		print '</div>';
1449
-		print '<div class="fichehalfright">';
1450
-		print '<div class="ficheaddleft">';
1451
-		print '<div class="underbanner clearboth"></div>';
1448
+        print '</div>';
1449
+        print '<div class="fichehalfright">';
1450
+        print '<div class="ficheaddleft">';
1451
+        print '<div class="underbanner clearboth"></div>';
1452 1452
 
1453 1453
 
1454
-		/*
1454
+        /*
1455 1455
 		 * Recurrence
1456 1456
 		 */
1457
-		$title = $langs->trans("Recurrence");
1458
-		//print load_fiche_titre($title, '', 'calendar');
1459
-
1460
-		print '<table class="border" width="100%">';
1461
-
1462
-		print '<tr><td colspan="2"><span class="fa fa-calendar"></span> '.$title.'</td></tr>';
1463
-
1464
-		// if "frequency" is empty or = 0, the reccurence is disabled
1465
-		print '<tr><td style="width: 50%">';
1466
-		print '<table class="nobordernopadding" width="100%"><tr><td>';
1467
-		print $langs->trans('Frequency');
1468
-		print '</td>';
1469
-		if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer)
1470
-			print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&amp;facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>';
1471
-		print '</tr></table>';
1472
-		print '</td><td>';
1473
-		if ($action == 'editfrequency')
1474
-		{
1475
-			print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">';
1476
-			print '<input type="hidden" name="action" value="setfrequency">';
1477
-			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1478
-			print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
1479
-			print '<tr><td>';
1480
-			print "<input type='text' name='frequency' value='".$object->frequency."' size='5' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m'));
1481
-			print '</td>';
1482
-			print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
1483
-			print '</tr></table></form>';
1484
-		}
1485
-		else
1486
-		{
1487
-				if ($object->frequency > 0)
1488
-				{
1489
-					print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
1490
-				}
1491
-				else
1492
-				{
1493
-					print $langs->trans("NotARecurringInvoiceTemplate");
1494
-			}
1495
-		}
1496
-		print '</td></tr>';
1497
-
1498
-		// Date when (next invoice generation)
1499
-		print '<tr><td>';
1500
-		if ($action == 'date_when' || $object->frequency > 0)
1501
-		{
1502
-			print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day');
1503
-		}
1504
-		else
1505
-		{
1506
-			print $langs->trans("NextDateToExecution");
1507
-		}
1508
-		print '</td><td>';
1509
-		if ($action == 'date_when' || $object->frequency > 0)
1510
-		{
1511
-			print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached');
1512
-		}
1513
-		//var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour'));
1514
-		if (! $object->isMaxNbGenReached())
1515
-		{
1516
-			if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
1517
-		}
1518
-		else
1519
-		{
1520
-			print img_info($langs->trans("MaxNumberOfGenerationReached"));
1521
-		}
1522
-		print '</td>';
1523
-		print '</tr>';
1524
-
1525
-		// Max period / Rest period
1526
-		print '<tr><td>';
1527
-		if ($action == 'nb_gen_max' || $object->frequency > 0)
1528
-		{
1529
-			print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
1530
-		}
1531
-		else
1532
-		{
1533
-			print $langs->trans("MaxPeriodNumber");
1534
-		}
1535
-		print '</td><td>';
1536
-		if ($action == 'nb_gen_max' || $object->frequency > 0)
1537
-		{
1538
-			  print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer);
1539
-		}
1540
-		else
1541
-		{
1542
-			print '';
1543
-		}
1544
-		print '</td>';
1545
-		print '</tr>';
1546
-
1547
-		// Status of generated invoices
1548
-		print '<tr><td>';
1549
-		if ($action == 'auto_validate' || $object->frequency > 0)
1550
-			print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
1551
-		else
1552
-			print $langs->trans("StatusOfGeneratedInvoices");
1553
-		print '</td><td>';
1554
-		$select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated');
1555
-		if ($action == 'auto_validate' || $object->frequency > 0)
1556
-		{
1557
-			print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select);
1558
-		}
1559
-		print '</td>';
1560
-		// Auto generate documents
1561
-		if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION))
1562
-		{
1563
-			print '<tr>';
1564
-			print '<td>';
1565
-			if ($action == 'generate_pdf' || $object->frequency > 0)
1566
-				print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer);
1567
-			else
1568
-				print $langs->trans("StatusOfGeneratedDocuments");
1569
-			print '</td>';
1570
-			print '<td>';
1571
-			$select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc');
1572
-			if ($action == 'generate_pdf' || $object->frequency > 0)
1573
-			{
1574
-				print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select);
1575
-			}
1576
-			print '</td>';
1577
-			print '</tr>';
1578
-		}
1579
-		else
1580
-		{
1581
-			print '<input type="hidden" name="generate_pdf" value="1">';
1582
-		}
1583
-
1584
-		print '</table>';
1585
-
1586
-		// Frequencry/Recurring section
1587
-		if ($object->frequency > 0)
1588
-		{
1589
-			print '<br>';
1590
-
1591
-			if (empty($conf->cron->enabled))
1592
-			{
1593
-				print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name")));
1594
-			}
1595
-
1596
-			print '<div class="underbanner clearboth"></div>';
1597
-			print '<table class="border centpercent">';
1598
-
1599
-			// Nb of generation already done
1600
-			print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>';
1601
-			print '<td>';
1602
-			print $object->nb_gen_done?$object->nb_gen_done:'0';
1603
-			print '</td>';
1604
-			print '</tr>';
1605
-
1606
-			// Date last
1607
-			print '<tr><td>';
1608
-			print $langs->trans("DateLastGeneration");
1609
-			print '</td><td>';
1610
-			print dol_print_date($object->date_last_gen, 'dayhour');
1611
-			print '</td>';
1612
-			print '</tr>';
1613
-
1614
-			print '</table>';
1615
-
1616
-			print '<br>';
1617
-		}
1618
-
1619
-		print '</div>';
1620
-		print '</div>';
1621
-		print '</div>';
1622
-
1623
-		print '<div class="clearboth"></div><br>';
1624
-
1625
-
1626
-		// Lines
1627
-		print '	<form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST">
1457
+        $title = $langs->trans("Recurrence");
1458
+        //print load_fiche_titre($title, '', 'calendar');
1459
+
1460
+        print '<table class="border" width="100%">';
1461
+
1462
+        print '<tr><td colspan="2"><span class="fa fa-calendar"></span> '.$title.'</td></tr>';
1463
+
1464
+        // if "frequency" is empty or = 0, the reccurence is disabled
1465
+        print '<tr><td style="width: 50%">';
1466
+        print '<table class="nobordernopadding" width="100%"><tr><td>';
1467
+        print $langs->trans('Frequency');
1468
+        print '</td>';
1469
+        if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer)
1470
+            print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&amp;facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>';
1471
+        print '</tr></table>';
1472
+        print '</td><td>';
1473
+        if ($action == 'editfrequency')
1474
+        {
1475
+            print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">';
1476
+            print '<input type="hidden" name="action" value="setfrequency">';
1477
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1478
+            print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
1479
+            print '<tr><td>';
1480
+            print "<input type='text' name='frequency' value='".$object->frequency."' size='5' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m'));
1481
+            print '</td>';
1482
+            print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
1483
+            print '</tr></table></form>';
1484
+        }
1485
+        else
1486
+        {
1487
+                if ($object->frequency > 0)
1488
+                {
1489
+                    print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
1490
+                }
1491
+                else
1492
+                {
1493
+                    print $langs->trans("NotARecurringInvoiceTemplate");
1494
+            }
1495
+        }
1496
+        print '</td></tr>';
1497
+
1498
+        // Date when (next invoice generation)
1499
+        print '<tr><td>';
1500
+        if ($action == 'date_when' || $object->frequency > 0)
1501
+        {
1502
+            print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day');
1503
+        }
1504
+        else
1505
+        {
1506
+            print $langs->trans("NextDateToExecution");
1507
+        }
1508
+        print '</td><td>';
1509
+        if ($action == 'date_when' || $object->frequency > 0)
1510
+        {
1511
+            print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached');
1512
+        }
1513
+        //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour'));
1514
+        if (! $object->isMaxNbGenReached())
1515
+        {
1516
+            if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
1517
+        }
1518
+        else
1519
+        {
1520
+            print img_info($langs->trans("MaxNumberOfGenerationReached"));
1521
+        }
1522
+        print '</td>';
1523
+        print '</tr>';
1524
+
1525
+        // Max period / Rest period
1526
+        print '<tr><td>';
1527
+        if ($action == 'nb_gen_max' || $object->frequency > 0)
1528
+        {
1529
+            print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
1530
+        }
1531
+        else
1532
+        {
1533
+            print $langs->trans("MaxPeriodNumber");
1534
+        }
1535
+        print '</td><td>';
1536
+        if ($action == 'nb_gen_max' || $object->frequency > 0)
1537
+        {
1538
+                print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer);
1539
+        }
1540
+        else
1541
+        {
1542
+            print '';
1543
+        }
1544
+        print '</td>';
1545
+        print '</tr>';
1546
+
1547
+        // Status of generated invoices
1548
+        print '<tr><td>';
1549
+        if ($action == 'auto_validate' || $object->frequency > 0)
1550
+            print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
1551
+        else
1552
+            print $langs->trans("StatusOfGeneratedInvoices");
1553
+        print '</td><td>';
1554
+        $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated');
1555
+        if ($action == 'auto_validate' || $object->frequency > 0)
1556
+        {
1557
+            print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select);
1558
+        }
1559
+        print '</td>';
1560
+        // Auto generate documents
1561
+        if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION))
1562
+        {
1563
+            print '<tr>';
1564
+            print '<td>';
1565
+            if ($action == 'generate_pdf' || $object->frequency > 0)
1566
+                print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer);
1567
+            else
1568
+                print $langs->trans("StatusOfGeneratedDocuments");
1569
+            print '</td>';
1570
+            print '<td>';
1571
+            $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc');
1572
+            if ($action == 'generate_pdf' || $object->frequency > 0)
1573
+            {
1574
+                print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select);
1575
+            }
1576
+            print '</td>';
1577
+            print '</tr>';
1578
+        }
1579
+        else
1580
+        {
1581
+            print '<input type="hidden" name="generate_pdf" value="1">';
1582
+        }
1583
+
1584
+        print '</table>';
1585
+
1586
+        // Frequencry/Recurring section
1587
+        if ($object->frequency > 0)
1588
+        {
1589
+            print '<br>';
1590
+
1591
+            if (empty($conf->cron->enabled))
1592
+            {
1593
+                print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name")));
1594
+            }
1595
+
1596
+            print '<div class="underbanner clearboth"></div>';
1597
+            print '<table class="border centpercent">';
1598
+
1599
+            // Nb of generation already done
1600
+            print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>';
1601
+            print '<td>';
1602
+            print $object->nb_gen_done?$object->nb_gen_done:'0';
1603
+            print '</td>';
1604
+            print '</tr>';
1605
+
1606
+            // Date last
1607
+            print '<tr><td>';
1608
+            print $langs->trans("DateLastGeneration");
1609
+            print '</td><td>';
1610
+            print dol_print_date($object->date_last_gen, 'dayhour');
1611
+            print '</td>';
1612
+            print '</tr>';
1613
+
1614
+            print '</table>';
1615
+
1616
+            print '<br>';
1617
+        }
1618
+
1619
+        print '</div>';
1620
+        print '</div>';
1621
+        print '</div>';
1622
+
1623
+        print '<div class="clearboth"></div><br>';
1624
+
1625
+
1626
+        // Lines
1627
+        print '	<form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST">
1628 1628
         	<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">
1629 1629
         	<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '">
1630 1630
         	<input type="hidden" name="mode" value="">
1631 1631
         	<input type="hidden" name="id" value="' . $object->id . '">
1632 1632
         	';
1633 1633
 
1634
-		if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
1635
-			include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
1636
-		}
1634
+        if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
1635
+            include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
1636
+        }
1637 1637
 
1638
-		print '<div class="div-table-responsive-no-min">';
1639
-		print '<table id="tablelines" class="noborder noshadow" width="100%">';
1640
-		// Show object lines
1641
-		if (! empty($object->lines))
1642
-		{
1643
-			//$disableedit=1;
1644
-			//$disablemove=1;
1645
-			$ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0);      // No date selector for template invoice
1646
-		}
1638
+        print '<div class="div-table-responsive-no-min">';
1639
+        print '<table id="tablelines" class="noborder noshadow" width="100%">';
1640
+        // Show object lines
1641
+        if (! empty($object->lines))
1642
+        {
1643
+            //$disableedit=1;
1644
+            //$disablemove=1;
1645
+            $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0);      // No date selector for template invoice
1646
+        }
1647 1647
 
1648
-		// Form to add new line
1649
-		if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline')
1650
-		{
1651
-			if ($action != 'editline')
1652
-			{
1653
-				// Add free products/services
1654
-				$object->formAddObjectLine(0, $mysoc, $object->thirdparty);                          // No date selector for template invoice
1648
+        // Form to add new line
1649
+        if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline')
1650
+        {
1651
+            if ($action != 'editline')
1652
+            {
1653
+                // Add free products/services
1654
+                $object->formAddObjectLine(0, $mysoc, $object->thirdparty);                          // No date selector for template invoice
1655 1655
 
1656
-				$parameters = array();
1657
-				$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1658
-			}
1659
-		}
1656
+                $parameters = array();
1657
+                $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1658
+            }
1659
+        }
1660 1660
 
1661
-		print "</table>\n";
1662
-		print '</div>';
1661
+        print "</table>\n";
1662
+        print '</div>';
1663 1663
 
1664
-		print "</form>\n";
1664
+        print "</form>\n";
1665 1665
 
1666
-		dol_fiche_end();
1666
+        dol_fiche_end();
1667 1667
 
1668 1668
 
1669
-		/**
1670
-		 * Barre d'actions
1671
-		 */
1672
-		print '<div class="tabsAction">';
1673
-
1674
-		if (empty($object->suspended))
1675
-		{
1676
-			if ($user->rights->facture->creer)
1677
-			{
1678
-				if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max))
1679
-				{
1680
-					print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>';
1681
-				}
1682
-				else
1683
-				{
1684
-					if (empty($object->frequency) || $object->date_when <= $today)
1685
-					{
1669
+        /**
1670
+         * Barre d'actions
1671
+         */
1672
+        print '<div class="tabsAction">';
1673
+
1674
+        if (empty($object->suspended))
1675
+        {
1676
+            if ($user->rights->facture->creer)
1677
+            {
1678
+                if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max))
1679
+                {
1680
+                    print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>';
1681
+                }
1682
+                else
1683
+                {
1684
+                    if (empty($object->frequency) || $object->date_when <= $today)
1685
+                    {
1686 1686
                         print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $object->thirdparty->id . '&fac_rec=' . $object->id . '">' . $langs->trans("CreateBill") . '</a></div>';
1687
-					}
1688
-					else
1689
-					{
1690
-						print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>';
1691
-					}
1692
-				}
1693
-			}
1694
-			else
1695
-			{
1696
-				print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateBill").'</a></div>';
1697
-			}
1698
-		}
1699
-
1700
-		if ($user->rights->facture->creer)
1701
-		{
1702
-			if (empty($object->suspended))
1703
-			{
1687
+                    }
1688
+                    else
1689
+                    {
1690
+                        print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>';
1691
+                    }
1692
+                }
1693
+            }
1694
+            else
1695
+            {
1696
+                print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateBill").'</a></div>';
1697
+            }
1698
+        }
1699
+
1700
+        if ($user->rights->facture->creer)
1701
+        {
1702
+            if (empty($object->suspended))
1703
+            {
1704 1704
                 print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=disable&id=' . $object->id . '">' . $langs->trans("Disable") . '</a></div>';
1705
-			}
1706
-			else
1707
-			{
1705
+            }
1706
+            else
1707
+            {
1708 1708
                 print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=enable&id=' . $object->id . '">' . $langs->trans("Enable") . '</a></div>';
1709
-			}
1710
-		}
1709
+            }
1710
+        }
1711 1711
 
1712
-		//if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
1713
-		if ($user->rights->facture->supprimer)
1714
-		{
1715
-			print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=ask_deleteinvoice&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
1716
-		}
1712
+        //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
1713
+        if ($user->rights->facture->supprimer)
1714
+        {
1715
+            print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=ask_deleteinvoice&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
1716
+        }
1717 1717
 
1718
-		print '</div>';
1718
+        print '</div>';
1719 1719
 
1720 1720
 
1721 1721
 
1722
-		print '<div class="fichecenter"><div class="fichehalfleft">';
1723
-		print '<a name="builddoc"></a>'; // ancre
1722
+        print '<div class="fichecenter"><div class="fichehalfleft">';
1723
+        print '<a name="builddoc"></a>'; // ancre
1724 1724
 
1725 1725
 
1726
-		// Show links to link elements
1727
-		$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
1726
+        // Show links to link elements
1727
+        $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
1728 1728
 
1729
-		$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1729
+        $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1730 1730
 
1731 1731
 
1732
-		print '</div></div>';
1733
-	}
1732
+        print '</div></div>';
1733
+    }
1734 1734
 }
1735 1735
 
1736 1736
 // End of page
Please login to merge, or discard this patch.