Passed
Push — master ( 5feb35...1007d6 )
by Alxarafe
33:05
created
dolibarr/htdocs/expedition/contact.php 3 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
 {
81 81
     if ($result > 0 && $id > 0)
82 82
     {
83
-  		$result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]);
83
+            $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]);
84 84
     }
85 85
 
86
-	if ($result >= 0)
87
-	{
88
-		header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
89
-		exit;
90
-	}
91
-	else
92
-	{
93
-		if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
94
-		{
95
-			$langs->load("errors");
96
-			$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
97
-		} else {
98
-			$mesg = $objectsrc->error;
99
-			$mesgs = $objectsrc->errors;
100
-		}
101
-		setEventMessages($mesg, $mesgs, 'errors');
102
-	}
86
+    if ($result >= 0)
87
+    {
88
+        header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
89
+        exit;
90
+    }
91
+    else
92
+    {
93
+        if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
94
+        {
95
+            $langs->load("errors");
96
+            $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
97
+        } else {
98
+            $mesg = $objectsrc->error;
99
+            $mesgs = $objectsrc->errors;
100
+        }
101
+        setEventMessages($mesg, $mesgs, 'errors');
102
+    }
103 103
 }
104 104
 
105 105
 // bascule du statut d'un contact
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 // Efface un contact
112 112
 else if ($action == 'deletecontact' && $user->rights->expedition->creer)
113 113
 {
114
-	$result = $objectsrc->delete_contact(GETPOST("lineid"));
115
-
116
-	if ($result >= 0)
117
-	{
118
-		header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
119
-		exit;
120
-	}
121
-	else {
122
-		dol_print_error($db);
123
-	}
114
+    $result = $objectsrc->delete_contact(GETPOST("lineid"));
115
+
116
+    if ($result >= 0)
117
+    {
118
+        header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
119
+        exit;
120
+    }
121
+    else {
122
+        dol_print_error($db);
123
+    }
124 124
 }
125 125
 /*
126 126
 else if ($action == 'setaddress' && $user->rights->expedition->creer)
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
 
153 153
 if ($id > 0 || ! empty($ref))
154 154
 {
155
-	$langs->trans("OrderCard");
155
+    $langs->trans("OrderCard");
156 156
 
157
-	$head = shipping_prepare_head($object);
158
-	dol_fiche_head($head, 'contact', $langs->trans("Shipment"), -1, 'sending');
157
+    $head = shipping_prepare_head($object);
158
+    dol_fiche_head($head, 'contact', $langs->trans("Shipment"), -1, 'sending');
159 159
 
160 160
 
161
-	// Shipment card
162
-	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">'.$langs->trans("BackToList").'</a>';
161
+    // Shipment card
162
+    $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">'.$langs->trans("BackToList").'</a>';
163 163
 
164
-	$morehtmlref='<div class="refidno">';
165
-	// Ref customer shipment
166
-	$morehtmlref.=$form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
167
-	$morehtmlref.=$form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
168
-	// Thirdparty
164
+    $morehtmlref='<div class="refidno">';
165
+    // Ref customer shipment
166
+    $morehtmlref.=$form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
167
+    $morehtmlref.=$form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
168
+    // Thirdparty
169 169
     $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
170 170
     // Project
171 171
     if (! empty($conf->projet->enabled)) {
@@ -201,70 +201,70 @@  discard block
 block discarded – undo
201 201
             }
202 202
         }
203 203
     }
204
-	$morehtmlref.='</div>';
204
+    $morehtmlref.='</div>';
205 205
 
206 206
 
207
-	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
207
+    dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
208 208
 
209 209
 
210
-	print '<div class="fichecenter">';
210
+    print '<div class="fichecenter">';
211 211
     //print '<div class="fichehalfleft">';
212
-	print '<div class="underbanner clearboth"></div>';
212
+    print '<div class="underbanner clearboth"></div>';
213 213
 
214 214
     print '<table class="border centpercent">';
215 215
 
216 216
     // Linked documents
217
-	if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
218
-	{
219
-	    print '<tr><td class="titlefield">';
220
-	    $objectsrc=new Commande($db);
221
-	    $objectsrc->fetch($object->$typeobject->id);
222
-	    print $langs->trans("RefOrder").'</td>';
223
-	    print '<td colspan="3">';
224
-	    print $objectsrc->getNomUrl(1,'commande');
225
-	    print "</td>\n";
226
-	    print '</tr>';
227
-	}
228
-	if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
229
-	{
230
-	    print '<tr><td class="titlefield">';
231
-	    $objectsrc=new Propal($db);
232
-	    $objectsrc->fetch($object->$typeobject->id);
233
-	    print $langs->trans("RefProposal").'</td>';
234
-	    print '<td colspan="3">';
235
-	    print $objectsrc->getNomUrl(1,'expedition');
236
-	    print "</td>\n";
237
-	    print '</tr>';
238
-	}
239
-
240
-	print "</table>";
241
-
242
-
243
-	//print '</div>';
244
-	//print '<div class="fichehalfright">';
245
-	//print '<div class="ficheaddleft">';
246
-	//print '<div class="underbanner clearboth"></div>';
247
-
248
-
249
-	//print '</div>';
250
-	//print '</div>';
251
-	print '</div>';
252
-
253
-	print '<div class="clearboth"></div>';
254
-
255
-
256
-	dol_fiche_end();
257
-
258
-	// Lignes de contacts
259
-	echo '<br>';
260
-
261
-	// Contacts lines (modules that overwrite templates must declare this into descriptor)
262
-	$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
263
-	foreach($dirtpls as $reldir)
264
-	{
265
-	    $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
266
-	    if ($res) break;
267
-	}
217
+    if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
218
+    {
219
+        print '<tr><td class="titlefield">';
220
+        $objectsrc=new Commande($db);
221
+        $objectsrc->fetch($object->$typeobject->id);
222
+        print $langs->trans("RefOrder").'</td>';
223
+        print '<td colspan="3">';
224
+        print $objectsrc->getNomUrl(1,'commande');
225
+        print "</td>\n";
226
+        print '</tr>';
227
+    }
228
+    if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
229
+    {
230
+        print '<tr><td class="titlefield">';
231
+        $objectsrc=new Propal($db);
232
+        $objectsrc->fetch($object->$typeobject->id);
233
+        print $langs->trans("RefProposal").'</td>';
234
+        print '<td colspan="3">';
235
+        print $objectsrc->getNomUrl(1,'expedition');
236
+        print "</td>\n";
237
+        print '</tr>';
238
+    }
239
+
240
+    print "</table>";
241
+
242
+
243
+    //print '</div>';
244
+    //print '<div class="fichehalfright">';
245
+    //print '<div class="ficheaddleft">';
246
+    //print '<div class="underbanner clearboth"></div>';
247
+
248
+
249
+    //print '</div>';
250
+    //print '</div>';
251
+    print '</div>';
252
+
253
+    print '<div class="clearboth"></div>';
254
+
255
+
256
+    dol_fiche_end();
257
+
258
+    // Lignes de contacts
259
+    echo '<br>';
260
+
261
+    // Contacts lines (modules that overwrite templates must declare this into descriptor)
262
+    $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
263
+    foreach($dirtpls as $reldir)
264
+    {
265
+        $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
266
+        if ($res) break;
267
+    }
268 268
 }
269 269
 
270 270
 // End of page
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 $action=GETPOST('action','alpha');
43 43
 
44 44
 // Security check
45
-if ($user->societe_id) $socid=$user->societe_id;
45
+if ($user->societe_id) {
46
+    $socid=$user->societe_id;
47
+}
46 48
 $result = restrictedArea($user, 'expedition', $id,'');
47 49
 
48 50
 $object = new Expedition($db);
@@ -87,8 +89,7 @@  discard block
 block discarded – undo
87 89
 	{
88 90
 		header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
89 91
 		exit;
90
-	}
91
-	else
92
+	} else
92 93
 	{
93 94
 		if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
94 95
 		{
@@ -117,8 +118,7 @@  discard block
 block discarded – undo
117 118
 	{
118 119
 		header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
119 120
 		exit;
120
-	}
121
-	else {
121
+	} else {
122 122
 		dol_print_error($db);
123 123
 	}
124 124
 }
@@ -263,7 +263,9 @@  discard block
 block discarded – undo
263 263
 	foreach($dirtpls as $reldir)
264 264
 	{
265 265
 	    $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
266
-	    if ($res) break;
266
+	    if ($res) {
267
+	        break;
268
+	    }
267 269
 	}
268 270
 }
269 271
 
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
27 27
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
28
-require DOL_BASE_PATH . '/main.inc.php';
29
-require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
28
+require DOL_BASE_PATH.'/main.inc.php';
29
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33 33
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34
-if (! empty($conf->projet->enabled)) {
34
+if (!empty($conf->projet->enabled)) {
35 35
     require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36 36
     require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37 37
 }
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 // Load translation files required by the page
40 40
 $langs->loadLangs(array('orders', 'sendings', 'companies'));
41 41
 
42
-$id=GETPOST('id','int');
43
-$ref=GETPOST('ref','alpha');
44
-$action=GETPOST('action','alpha');
42
+$id = GETPOST('id', 'int');
43
+$ref = GETPOST('ref', 'alpha');
44
+$action = GETPOST('action', 'alpha');
45 45
 
46 46
 // Security check
47
-if ($user->societe_id) $socid=$user->societe_id;
48
-$result = restrictedArea($user, 'expedition', $id,'');
47
+if ($user->societe_id) $socid = $user->societe_id;
48
+$result = restrictedArea($user, 'expedition', $id, '');
49 49
 
50 50
 $object = new Expedition($db);
51
-if ($id > 0 || ! empty($ref))
51
+if ($id > 0 || !empty($ref))
52 52
 {
53 53
     $object->fetch($id, $ref);
54 54
     $object->fetch_thirdparty();
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
     }
62 62
 
63 63
     // Linked documents
64
-    if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
64
+    if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
65 65
     {
66
-        $objectsrc=new Commande($db);
66
+        $objectsrc = new Commande($db);
67 67
         $objectsrc->fetch($object->$typeobject->id);
68 68
     }
69
-    if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
69
+    if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
70 70
     {
71
-        $objectsrc=new Propal($db);
71
+        $objectsrc = new Propal($db);
72 72
         $objectsrc->fetch($object->$typeobject->id);
73 73
     }
74 74
 }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 // bascule du statut d'un contact
108 108
 else if ($action == 'swapstatut' && $user->rights->expedition->creer)
109 109
 {
110
-    $result=$objectsrc->swapContactStatus(GETPOST('ligne'));
110
+    $result = $objectsrc->swapContactStatus(GETPOST('ligne'));
111 111
 }
112 112
 
113 113
 // Efface un contact
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
  * View
138 138
  */
139 139
 
140
-llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes');
140
+llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes');
141 141
 
142 142
 $form = new Form($db);
143 143
 $formcompany = new FormCompany($db);
144 144
 $formother = new FormOther($db);
145
-$contactstatic=new Contact($db);
146
-$userstatic=new User($db);
145
+$contactstatic = new Contact($db);
146
+$userstatic = new User($db);
147 147
 
148 148
 
149 149
 /* *************************************************************************** */
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 /*                                                                             */
153 153
 /* *************************************************************************** */
154 154
 
155
-if ($id > 0 || ! empty($ref))
155
+if ($id > 0 || !empty($ref))
156 156
 {
157 157
 	$langs->trans("OrderCard");
158 158
 
@@ -161,41 +161,41 @@  discard block
 block discarded – undo
161 161
 
162 162
 
163 163
 	// Shipment card
164
-	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">'.$langs->trans("BackToList").'</a>';
164
+	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
165 165
 
166
-	$morehtmlref='<div class="refidno">';
166
+	$morehtmlref = '<div class="refidno">';
167 167
 	// Ref customer shipment
168
-	$morehtmlref.=$form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
169
-	$morehtmlref.=$form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
168
+	$morehtmlref .= $form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
169
+	$morehtmlref .= $form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
170 170
 	// Thirdparty
171
-    $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
171
+    $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
172 172
     // Project
173
-    if (! empty($conf->projet->enabled)) {
173
+    if (!empty($conf->projet->enabled)) {
174 174
         $langs->load("projects");
175
-        $morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
175
+        $morehtmlref .= '<br>'.$langs->trans('Project').' ';
176 176
         if (0) {    // Do not change on shipment
177 177
             if ($action != 'classify') {
178
-                $morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
178
+                $morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
179 179
             }
180 180
             if ($action == 'classify') {
181 181
                 // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
182
-                $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
182
+                $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
183 183
                 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
184
-                $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
184
+                $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
185 185
                 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
186
-                $morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
186
+                $morehtmlref .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
187 187
                 $morehtmlref .= '</form>';
188 188
             } else {
189
-                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
189
+                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
190 190
             }
191 191
         } else {
192 192
             // We don't have project on shipment, so we will use the project or source object instead
193 193
             // TODO Add project on shipment
194 194
             $morehtmlref .= ' : ';
195
-            if (! empty($objectsrc->fk_project)) {
195
+            if (!empty($objectsrc->fk_project)) {
196 196
                 $proj = new Project($db);
197 197
                 $proj->fetch($objectsrc->fk_project);
198
-                $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
198
+                $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objectsrc->fk_project.'" title="'.$langs->trans('ShowProject').'">';
199 199
                 $morehtmlref .= $proj->ref;
200 200
                 $morehtmlref .= '</a>';
201 201
             } else {
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             }
204 204
         }
205 205
     }
206
-	$morehtmlref.='</div>';
206
+	$morehtmlref .= '</div>';
207 207
 
208 208
 
209 209
 	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -216,25 +216,25 @@  discard block
 block discarded – undo
216 216
     print '<table class="border centpercent">';
217 217
 
218 218
     // Linked documents
219
-	if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
219
+	if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
220 220
 	{
221 221
 	    print '<tr><td class="titlefield">';
222
-	    $objectsrc=new Commande($db);
222
+	    $objectsrc = new Commande($db);
223 223
 	    $objectsrc->fetch($object->$typeobject->id);
224 224
 	    print $langs->trans("RefOrder").'</td>';
225 225
 	    print '<td colspan="3">';
226
-	    print $objectsrc->getNomUrl(1,'commande');
226
+	    print $objectsrc->getNomUrl(1, 'commande');
227 227
 	    print "</td>\n";
228 228
 	    print '</tr>';
229 229
 	}
230
-	if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
230
+	if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
231 231
 	{
232 232
 	    print '<tr><td class="titlefield">';
233
-	    $objectsrc=new Propal($db);
233
+	    $objectsrc = new Propal($db);
234 234
 	    $objectsrc->fetch($object->$typeobject->id);
235 235
 	    print $langs->trans("RefProposal").'</td>';
236 236
 	    print '<td colspan="3">';
237
-	    print $objectsrc->getNomUrl(1,'expedition');
237
+	    print $objectsrc->getNomUrl(1, 'expedition');
238 238
 	    print "</td>\n";
239 239
 	    print '</tr>';
240 240
 	}
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 	echo '<br>';
262 262
 
263 263
 	// Contacts lines (modules that overwrite templates must declare this into descriptor)
264
-	$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
265
-	foreach($dirtpls as $reldir)
264
+	$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
265
+	foreach ($dirtpls as $reldir)
266 266
 	{
267
-	    $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
267
+	    $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
268 268
 	    if ($res) break;
269 269
 	}
270 270
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/list.php 3 patches
Indentation   +430 added lines, -430 removed lines patch added patch discarded remove patch
@@ -81,38 +81,38 @@  discard block
 block discarded – undo
81 81
 
82 82
 // List of fields to search into when doing a "search in all"
83 83
 $fieldstosearchall = array(
84
-	'e.ref'=>"Ref",
85
-	's.nom'=>"ThirdParty",
86
-	'e.note_public'=>'NotePublic',
84
+    'e.ref'=>"Ref",
85
+    's.nom'=>"ThirdParty",
86
+    'e.note_public'=>'NotePublic',
87 87
 );
88 88
 if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate";
89 89
 
90 90
 $checkedtypetiers=0;
91 91
 $arrayfields=array(
92
-	'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
93
-	'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
94
-	's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
95
-	's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
96
-	's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
97
-	'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
98
-	'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
99
-	'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
100
-	'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
101
-	'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
102
-	'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
103
-	'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
104
-	'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
105
-	'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
106
-	'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
92
+    'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
93
+    'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
94
+    's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
95
+    's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
96
+    's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
97
+    'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
98
+    'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
99
+    'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
100
+    'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
101
+    'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
102
+    'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
103
+    'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
104
+    'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
105
+    'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
106
+    'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
107 107
 );
108 108
 
109 109
 // Extra fields
110 110
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
111 111
 {
112
-	foreach($extrafields->attribute_label as $key => $val)
113
-	{
114
-		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]));
115
-	}
112
+    foreach($extrafields->attribute_label as $key => $val)
113
+    {
114
+        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]));
115
+    }
116 116
 }
117 117
 
118 118
 
@@ -132,36 +132,36 @@  discard block
 block discarded – undo
132 132
 // Purge search criteria
133 133
 if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
134 134
 {
135
-	$search_ref_exp='';
136
-	$search_ref_liv='';
137
-	$search_ref_customer='';
138
-	$search_company='';
139
-	$search_town='';
140
-	$search_zip="";
141
-	$search_state="";
142
-	$search_type='';
143
-	$search_country='';
144
-	$search_type_thirdparty='';
145
-	$search_billed='';
146
-	$viewstatut='';
147
-	$search_array_options=array();
135
+    $search_ref_exp='';
136
+    $search_ref_liv='';
137
+    $search_ref_customer='';
138
+    $search_company='';
139
+    $search_town='';
140
+    $search_zip="";
141
+    $search_state="";
142
+    $search_type='';
143
+    $search_country='';
144
+    $search_type_thirdparty='';
145
+    $search_billed='';
146
+    $viewstatut='';
147
+    $search_array_options=array();
148 148
 }
149 149
 
150 150
 if (empty($reshook))
151 151
 {
152
-	// Mass actions. Controls on number of lines checked
153
-	$maxformassaction=1000;
154
-	$numtoselect = (is_array($toselect)?count($toselect):0);
155
-	if (! empty($massaction) && $numtoselect < 1)
156
-	{
157
-		$error++;
158
-		setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
159
-	}
160
-	if (! $error && $numtoselect > $maxformassaction)
161
-	{
162
-		setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
163
-		$error++;
164
-	}
152
+    // Mass actions. Controls on number of lines checked
153
+    $maxformassaction=1000;
154
+    $numtoselect = (is_array($toselect)?count($toselect):0);
155
+    if (! empty($massaction) && $numtoselect < 1)
156
+    {
157
+        $error++;
158
+        setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
159
+    }
160
+    if (! $error && $numtoselect > $maxformassaction)
161
+    {
162
+        setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
163
+        $error++;
164
+    }
165 165
 }
166 166
 
167 167
 
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
201 201
 if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
202 202
 {
203
-	$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
203
+    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
204 204
 }
205 205
 $sql.= " WHERE e.entity IN (".getEntity('expedition').")";
206 206
 if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
207 207
 {
208
-	$sql.= " AND e.fk_soc = sc.fk_soc";
209
-	$sql.= " AND sc.fk_user = " .$user->id;
208
+    $sql.= " AND e.fk_soc = sc.fk_soc";
209
+    $sql.= " AND sc.fk_user = " .$user->id;
210 210
 }
211 211
 if ($socid)
212 212
 {
213
-	$sql.= " AND e.fk_soc = ".$socid;
213
+    $sql.= " AND e.fk_soc = ".$socid;
214 214
 }
215 215
 if ($viewstatut <> '' && $viewstatut >= 0) {
216
-	$sql.= " AND e.fk_statut = ".$viewstatut;
216
+    $sql.= " AND e.fk_statut = ".$viewstatut;
217 217
 }
218 218
 if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer);
219 219
 if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed;
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 $nbtotalofrecords = '';
241 241
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
242 242
 {
243
-	$result = $db->query($sql);
244
-	$nbtotalofrecords = $db->num_rows($result);
245
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
246
-	{
247
-		$page = 0;
248
-		$offset = 0;
249
-	}
243
+    $result = $db->query($sql);
244
+    $nbtotalofrecords = $db->num_rows($result);
245
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
246
+    {
247
+        $page = 0;
248
+        $offset = 0;
249
+    }
250 250
 }
251 251
 
252 252
 $sql.= $db->plimit($limit + 1,$offset);
@@ -255,382 +255,382 @@  discard block
 block discarded – undo
255 255
 $resql=$db->query($sql);
256 256
 if ($resql)
257 257
 {
258
-	$num = $db->num_rows($resql);
259
-
260
-	$expedition = new Expedition($db);
261
-
262
-	$param='';
263
-	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
264
-	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
265
-	if ($sall) $param.= "&amp;sall=".urlencode($sall);
266
-	if ($search_ref_exp)  $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
267
-	if ($search_ref_liv)  $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
268
-	if ($search_ref_customer) $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
269
-	if ($search_company)   $param.= "&amp;search_company=".urlencode($search_company);
270
-	if ($search_town)      $param.= '&search_town='.urlencode($search_town);
271
-	if ($search_zip)       $param.= '&search_zip='.urlencode($search_zip);
272
-	if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut);
273
-	if ($optioncss != '')  $param.='&amp;optioncss='.urlencode($optioncss);
274
-	// Add $param from extra fields
275
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
276
-
277
-	//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
278
-
279
-	$newcardbutton='';
280
-	if ($user->rights->expedition->creer)
281
-	{
282
-		$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
283
-		$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
284
-		$newcardbutton.= '</a>';
285
-	}
286
-
287
-	$i = 0;
288
-	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
289
-	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
290
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
291
-	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
292
-	print '<input type="hidden" name="action" value="list">';
293
-	print '<input type="hidden" name="page" value="'.$page.'">';
294
-	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
295
-	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
296
-
297
-	print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
298
-
299
-	if ($sall)
300
-	{
301
-		foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
302
-		print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
303
-	}
304
-
305
-	$moreforfilter='';
306
-	if (! empty($moreforfilter))
307
-	{
308
-		print '<div class="liste_titre liste_titre_bydiv centpercent">';
309
-		print $moreforfilter;
310
-		$parameters=array('type'=>$type);
311
-		$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
312
-		print $hookmanager->resPrint;
313
-		print '</div>';
314
-	}
315
-
316
-	$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
317
-	$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
318
-
319
-	print '<div class="div-table-responsive">';
320
-	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
321
-
322
-	// Lignes des champs de filtre
323
-	print '<tr class="liste_titre_filter">';
324
-	// Ref
325
-	if (! empty($arrayfields['e.ref']['checked']))
326
-	{
327
-		print '<td class="liste_titre">';
328
-		print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
329
-		print '</td>';
330
-	}
331
-	// Ref customer
332
-	if (! empty($arrayfields['e.ref_customer']['checked']))
333
-	{
334
-		print '<td class="liste_titre">';
335
-		print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
336
-		print '</td>';
337
-	}
338
-	// Thirdparty
339
-	if (! empty($arrayfields['s.nom']['checked']))
340
-	{
341
-		print '<td class="liste_titre" align="left">';
342
-		print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
343
-		print '</td>';
344
-	}
345
-	// Town
346
-	if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
347
-	// Zip
348
-	if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
349
-	// State
350
-	if (! empty($arrayfields['state.nom']['checked']))
351
-	{
352
-		print '<td class="liste_titre">';
353
-		print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
354
-		print '</td>';
355
-	}
356
-	// Country
357
-	if (! empty($arrayfields['country.code_iso']['checked']))
358
-	{
359
-		print '<td class="liste_titre" align="center">';
360
-		print $form->select_country($search_country,'search_country','',0,'maxwidth100');
361
-		print '</td>';
362
-	}
363
-	// Company type
364
-	if (! empty($arrayfields['typent.code']['checked']))
365
-	{
366
-		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
367
-		print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
368
-		print '</td>';
369
-	}
370
-	// Date delivery planned
371
-	if (! empty($arrayfields['e.date_delivery']['checked']))
372
-	{
373
-		print '<td class="liste_titre">&nbsp;</td>';
374
-	}
375
-	if (! empty($arrayfields['l.ref']['checked']))
376
-	{
377
-		// Delivery ref
378
-		print '<td class="liste_titre">';
379
-		print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
380
-		print '</td>';
381
-	}
382
-	if (! empty($arrayfields['l.date_delivery']['checked']))
383
-	{
384
-		// Date received
385
-		print '<td class="liste_titre">&nbsp;</td>';
386
-	}
387
-	// Extra fields
388
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
389
-
390
-	// Fields from hook
391
-	$parameters=array('arrayfields'=>$arrayfields);
392
-	$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
393
-	print $hookmanager->resPrint;
394
-	// Date creation
395
-	if (! empty($arrayfields['e.datec']['checked']))
396
-	{
397
-		print '<td class="liste_titre">';
398
-		print '</td>';
399
-	}
400
-	// Date modification
401
-	if (! empty($arrayfields['e.tms']['checked']))
402
-	{
403
-		print '<td class="liste_titre">';
404
-		print '</td>';
405
-	}
406
-	// Status
407
-	if (! empty($arrayfields['e.fk_statut']['checked']))
408
-	{
409
-		print '<td class="liste_titre maxwidthonsmartphone" align="right">';
410
-		print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')),$viewstatut,1);
411
-		print '</td>';
412
-	}
413
-	// Status billed
414
-	if (! empty($arrayfields['e.billed']['checked']))
415
-	{
416
-		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
417
-		print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
418
-		print '</td>';
419
-	}
420
-	// Action column
421
-	print '<td class="liste_titre" align="middle">';
422
-	$searchpicto=$form->showFilterAndCheckAddButtons(0);
423
-	print $searchpicto;
424
-	print '</td>';
425
-	print "</tr>\n";
426
-
427
-	print '<tr class="liste_titre">';
428
-	if (! empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
429
-	if (! empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
430
-	if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
431
-	if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
432
-	if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
433
-	if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
434
-	if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
435
-	if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
436
-	if (! empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
437
-	if (! empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
438
-	if (! empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
439
-	// Extra fields
440
-	if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
441
-	{
442
-		foreach($extrafields->attribute_label as $key => $val)
443
-		{
444
-			if (! empty($arrayfields["ef.".$key]['checked']))
445
-			{
446
-				$align=$extrafields->getAlignFlag($key);
447
-				$sortonfield = "ef.".$key;
448
-				if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
449
-				print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
450
-			}
451
-		}
452
-	}
453
-	// Hook fields
454
-	$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
455
-	$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
456
-	print $hookmanager->resPrint;
457
-	if (! empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
458
-	if (! empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
459
-	if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
460
-	if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
461
-	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
462
-	print "</tr>\n";
463
-
464
-	$i=0;
465
-	$totalarray=array();
466
-	while ($i < min($num,$limit))
467
-	{
468
-		$obj = $db->fetch_object($resql);
469
-
470
-		$shipment->id=$obj->rowid;
471
-		$shipment->ref=$obj->ref;
472
-
473
-		$companystatic->id=$obj->socid;
474
-		$companystatic->ref=$obj->name;
475
-		$companystatic->name=$obj->name;
476
-
477
-
478
-		print '<tr class="oddeven">';
479
-
480
-		// Ref
481
-		if (! empty($arrayfields['e.ref']['checked']))
482
-		{
483
-			print "<td>";
484
-			print $shipment->getNomUrl(1);
485
-			print "</td>\n";
486
-			if (! $i) $totalarray['nbfield']++;
487
-		}
488
-
489
-		// Ref customer
490
-		if (! empty($arrayfields['e.ref_customer']['checked']))
491
-		{
492
-			print "<td>";
493
-			print $obj->ref_customer;
494
-			print "</td>\n";
495
-			if (! $i) $totalarray['nbfield']++;
496
-		}
497
-
498
-		// Third party
499
-		if (! empty($arrayfields['s.nom']['checked']))
500
-		{
501
-			print '<td>';
502
-			print $companystatic->getNomUrl(1);
503
-			print '</td>';
504
-			if (! $i) $totalarray['nbfield']++;
505
-		}
506
-		// Town
507
-		if (! empty($arrayfields['s.town']['checked']))
508
-		{
509
-			print '<td class="nocellnopadd">';
510
-			print $obj->town;
511
-			print '</td>';
512
-			if (! $i) $totalarray['nbfield']++;
513
-		}
514
-		// Zip
515
-		if (! empty($arrayfields['s.zip']['checked']))
516
-		{
517
-			print '<td class="nocellnopadd">';
518
-			print $obj->zip;
519
-			print '</td>';
520
-			if (! $i) $totalarray['nbfield']++;
521
-		}
522
-		// State
523
-		if (! empty($arrayfields['state.nom']['checked']))
524
-		{
525
-			print "<td>".$obj->state_name."</td>\n";
526
-			if (! $i) $totalarray['nbfield']++;
527
-		}
528
-		// Country
529
-		if (! empty($arrayfields['country.code_iso']['checked']))
530
-		{
531
-			print '<td align="center">';
532
-			$tmparray=getCountry($obj->fk_pays,'all');
533
-			print $tmparray['label'];
534
-			print '</td>';
535
-			if (! $i) $totalarray['nbfield']++;
536
-		}
537
-		// Type ent
538
-		if (! empty($arrayfields['typent.code']['checked']))
539
-		{
540
-			print '<td align="center">';
541
-			if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
542
-			print $typenArray[$obj->typent_code];
543
-			print '</td>';
544
-			if (! $i) $totalarray['nbfield']++;
545
-		}
546
-
547
-		// Date delivery planed
548
-		if (! empty($arrayfields['e.date_delivery']['checked']))
549
-		{
550
-			print '<td align="center">';
551
-			print dol_print_date($db->jdate($obj->date_livraison),"day");
552
-			/*$now = time();
258
+    $num = $db->num_rows($resql);
259
+
260
+    $expedition = new Expedition($db);
261
+
262
+    $param='';
263
+    if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
264
+    if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
265
+    if ($sall) $param.= "&amp;sall=".urlencode($sall);
266
+    if ($search_ref_exp)  $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
267
+    if ($search_ref_liv)  $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
268
+    if ($search_ref_customer) $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
269
+    if ($search_company)   $param.= "&amp;search_company=".urlencode($search_company);
270
+    if ($search_town)      $param.= '&search_town='.urlencode($search_town);
271
+    if ($search_zip)       $param.= '&search_zip='.urlencode($search_zip);
272
+    if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut);
273
+    if ($optioncss != '')  $param.='&amp;optioncss='.urlencode($optioncss);
274
+    // Add $param from extra fields
275
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
276
+
277
+    //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
278
+
279
+    $newcardbutton='';
280
+    if ($user->rights->expedition->creer)
281
+    {
282
+        $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
283
+        $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
284
+        $newcardbutton.= '</a>';
285
+    }
286
+
287
+    $i = 0;
288
+    print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
289
+    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
290
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
291
+    print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
292
+    print '<input type="hidden" name="action" value="list">';
293
+    print '<input type="hidden" name="page" value="'.$page.'">';
294
+    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
295
+    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
296
+
297
+    print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
298
+
299
+    if ($sall)
300
+    {
301
+        foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
302
+        print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
303
+    }
304
+
305
+    $moreforfilter='';
306
+    if (! empty($moreforfilter))
307
+    {
308
+        print '<div class="liste_titre liste_titre_bydiv centpercent">';
309
+        print $moreforfilter;
310
+        $parameters=array('type'=>$type);
311
+        $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
312
+        print $hookmanager->resPrint;
313
+        print '</div>';
314
+    }
315
+
316
+    $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
317
+    $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
318
+
319
+    print '<div class="div-table-responsive">';
320
+    print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
321
+
322
+    // Lignes des champs de filtre
323
+    print '<tr class="liste_titre_filter">';
324
+    // Ref
325
+    if (! empty($arrayfields['e.ref']['checked']))
326
+    {
327
+        print '<td class="liste_titre">';
328
+        print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
329
+        print '</td>';
330
+    }
331
+    // Ref customer
332
+    if (! empty($arrayfields['e.ref_customer']['checked']))
333
+    {
334
+        print '<td class="liste_titre">';
335
+        print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
336
+        print '</td>';
337
+    }
338
+    // Thirdparty
339
+    if (! empty($arrayfields['s.nom']['checked']))
340
+    {
341
+        print '<td class="liste_titre" align="left">';
342
+        print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
343
+        print '</td>';
344
+    }
345
+    // Town
346
+    if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
347
+    // Zip
348
+    if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
349
+    // State
350
+    if (! empty($arrayfields['state.nom']['checked']))
351
+    {
352
+        print '<td class="liste_titre">';
353
+        print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
354
+        print '</td>';
355
+    }
356
+    // Country
357
+    if (! empty($arrayfields['country.code_iso']['checked']))
358
+    {
359
+        print '<td class="liste_titre" align="center">';
360
+        print $form->select_country($search_country,'search_country','',0,'maxwidth100');
361
+        print '</td>';
362
+    }
363
+    // Company type
364
+    if (! empty($arrayfields['typent.code']['checked']))
365
+    {
366
+        print '<td class="liste_titre maxwidthonsmartphone" align="center">';
367
+        print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
368
+        print '</td>';
369
+    }
370
+    // Date delivery planned
371
+    if (! empty($arrayfields['e.date_delivery']['checked']))
372
+    {
373
+        print '<td class="liste_titre">&nbsp;</td>';
374
+    }
375
+    if (! empty($arrayfields['l.ref']['checked']))
376
+    {
377
+        // Delivery ref
378
+        print '<td class="liste_titre">';
379
+        print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
380
+        print '</td>';
381
+    }
382
+    if (! empty($arrayfields['l.date_delivery']['checked']))
383
+    {
384
+        // Date received
385
+        print '<td class="liste_titre">&nbsp;</td>';
386
+    }
387
+    // Extra fields
388
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
389
+
390
+    // Fields from hook
391
+    $parameters=array('arrayfields'=>$arrayfields);
392
+    $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
393
+    print $hookmanager->resPrint;
394
+    // Date creation
395
+    if (! empty($arrayfields['e.datec']['checked']))
396
+    {
397
+        print '<td class="liste_titre">';
398
+        print '</td>';
399
+    }
400
+    // Date modification
401
+    if (! empty($arrayfields['e.tms']['checked']))
402
+    {
403
+        print '<td class="liste_titre">';
404
+        print '</td>';
405
+    }
406
+    // Status
407
+    if (! empty($arrayfields['e.fk_statut']['checked']))
408
+    {
409
+        print '<td class="liste_titre maxwidthonsmartphone" align="right">';
410
+        print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')),$viewstatut,1);
411
+        print '</td>';
412
+    }
413
+    // Status billed
414
+    if (! empty($arrayfields['e.billed']['checked']))
415
+    {
416
+        print '<td class="liste_titre maxwidthonsmartphone" align="center">';
417
+        print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
418
+        print '</td>';
419
+    }
420
+    // Action column
421
+    print '<td class="liste_titre" align="middle">';
422
+    $searchpicto=$form->showFilterAndCheckAddButtons(0);
423
+    print $searchpicto;
424
+    print '</td>';
425
+    print "</tr>\n";
426
+
427
+    print '<tr class="liste_titre">';
428
+    if (! empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
429
+    if (! empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
430
+    if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
431
+    if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
432
+    if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
433
+    if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
434
+    if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
435
+    if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
436
+    if (! empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
437
+    if (! empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
438
+    if (! empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
439
+    // Extra fields
440
+    if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
441
+    {
442
+        foreach($extrafields->attribute_label as $key => $val)
443
+        {
444
+            if (! empty($arrayfields["ef.".$key]['checked']))
445
+            {
446
+                $align=$extrafields->getAlignFlag($key);
447
+                $sortonfield = "ef.".$key;
448
+                if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
449
+                print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
450
+            }
451
+        }
452
+    }
453
+    // Hook fields
454
+    $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
455
+    $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
456
+    print $hookmanager->resPrint;
457
+    if (! empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
458
+    if (! empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
459
+    if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
460
+    if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
461
+    print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
462
+    print "</tr>\n";
463
+
464
+    $i=0;
465
+    $totalarray=array();
466
+    while ($i < min($num,$limit))
467
+    {
468
+        $obj = $db->fetch_object($resql);
469
+
470
+        $shipment->id=$obj->rowid;
471
+        $shipment->ref=$obj->ref;
472
+
473
+        $companystatic->id=$obj->socid;
474
+        $companystatic->ref=$obj->name;
475
+        $companystatic->name=$obj->name;
476
+
477
+
478
+        print '<tr class="oddeven">';
479
+
480
+        // Ref
481
+        if (! empty($arrayfields['e.ref']['checked']))
482
+        {
483
+            print "<td>";
484
+            print $shipment->getNomUrl(1);
485
+            print "</td>\n";
486
+            if (! $i) $totalarray['nbfield']++;
487
+        }
488
+
489
+        // Ref customer
490
+        if (! empty($arrayfields['e.ref_customer']['checked']))
491
+        {
492
+            print "<td>";
493
+            print $obj->ref_customer;
494
+            print "</td>\n";
495
+            if (! $i) $totalarray['nbfield']++;
496
+        }
497
+
498
+        // Third party
499
+        if (! empty($arrayfields['s.nom']['checked']))
500
+        {
501
+            print '<td>';
502
+            print $companystatic->getNomUrl(1);
503
+            print '</td>';
504
+            if (! $i) $totalarray['nbfield']++;
505
+        }
506
+        // Town
507
+        if (! empty($arrayfields['s.town']['checked']))
508
+        {
509
+            print '<td class="nocellnopadd">';
510
+            print $obj->town;
511
+            print '</td>';
512
+            if (! $i) $totalarray['nbfield']++;
513
+        }
514
+        // Zip
515
+        if (! empty($arrayfields['s.zip']['checked']))
516
+        {
517
+            print '<td class="nocellnopadd">';
518
+            print $obj->zip;
519
+            print '</td>';
520
+            if (! $i) $totalarray['nbfield']++;
521
+        }
522
+        // State
523
+        if (! empty($arrayfields['state.nom']['checked']))
524
+        {
525
+            print "<td>".$obj->state_name."</td>\n";
526
+            if (! $i) $totalarray['nbfield']++;
527
+        }
528
+        // Country
529
+        if (! empty($arrayfields['country.code_iso']['checked']))
530
+        {
531
+            print '<td align="center">';
532
+            $tmparray=getCountry($obj->fk_pays,'all');
533
+            print $tmparray['label'];
534
+            print '</td>';
535
+            if (! $i) $totalarray['nbfield']++;
536
+        }
537
+        // Type ent
538
+        if (! empty($arrayfields['typent.code']['checked']))
539
+        {
540
+            print '<td align="center">';
541
+            if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
542
+            print $typenArray[$obj->typent_code];
543
+            print '</td>';
544
+            if (! $i) $totalarray['nbfield']++;
545
+        }
546
+
547
+        // Date delivery planed
548
+        if (! empty($arrayfields['e.date_delivery']['checked']))
549
+        {
550
+            print '<td align="center">';
551
+            print dol_print_date($db->jdate($obj->date_livraison),"day");
552
+            /*$now = time();
553 553
     		if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
554 554
     		{
555 555
     		}*/
556
-			print "</td>\n";
557
-		}
558
-
559
-		if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked']))
560
-		{
561
-			$shipment->fetchObjectLinked($shipment->id,$shipment->element);
562
-			$receiving='';
563
-			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']);
564
-
565
-			if (! empty($arrayfields['l.ref']['checked']))
566
-			{
567
-				// Ref
568
-				print '<td>';
569
-				print !empty($receiving) ? $receiving->getNomUrl($db) : '';
570
-				print '</td>';
571
-			}
572
-
573
-			if (! empty($arrayfields['l.date_delivery']['checked']))
574
-			{
575
-				// Date received
576
-				print '<td align="center">';
577
-				print dol_print_date($db->jdate($obj->date_reception),"day");
578
-				print '</td>'."\n";
579
-			}
580
-		}
581
-
582
-		// Extra fields
583
-		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
584
-		// Fields from hook
585
-		$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
586
-		$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
587
-		print $hookmanager->resPrint;
588
-		// Date creation
589
-		if (! empty($arrayfields['e.datec']['checked']))
590
-		{
591
-			print '<td align="center" class="nowrap">';
592
-			print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
593
-			print '</td>';
594
-			if (! $i) $totalarray['nbfield']++;
595
-		}
596
-		// Date modification
597
-		if (! empty($arrayfields['e.tms']['checked']))
598
-		{
599
-			print '<td align="center" class="nowrap">';
600
-			print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
601
-			print '</td>';
602
-			if (! $i) $totalarray['nbfield']++;
603
-		}
604
-		// Status
605
-		if (! empty($arrayfields['e.fk_statut']['checked']))
606
-		{
607
-			print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut,5).'</td>';
608
-			if (! $i) $totalarray['nbfield']++;
609
-		}
610
-		// Billed
611
-		if (! empty($arrayfields['e.billed']['checked']))
612
-		{
613
-			print '<td align="center">'.yn($obj->billed).'</td>';
614
-			if (! $i) $totalarray['nbfield']++;
615
-		}
616
-
617
-		// Action column
618
-		print '<td></td>';
619
-		if (! $i) $totalarray['nbfield']++;
620
-
621
-		print "</tr>\n";
622
-
623
-		$i++;
624
-	}
625
-
626
-	print "</table>";
627
-	print "</div>";
628
-	print '</form>';
629
-	$db->free($resql);
556
+            print "</td>\n";
557
+        }
558
+
559
+        if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked']))
560
+        {
561
+            $shipment->fetchObjectLinked($shipment->id,$shipment->element);
562
+            $receiving='';
563
+            if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']);
564
+
565
+            if (! empty($arrayfields['l.ref']['checked']))
566
+            {
567
+                // Ref
568
+                print '<td>';
569
+                print !empty($receiving) ? $receiving->getNomUrl($db) : '';
570
+                print '</td>';
571
+            }
572
+
573
+            if (! empty($arrayfields['l.date_delivery']['checked']))
574
+            {
575
+                // Date received
576
+                print '<td align="center">';
577
+                print dol_print_date($db->jdate($obj->date_reception),"day");
578
+                print '</td>'."\n";
579
+            }
580
+        }
581
+
582
+        // Extra fields
583
+        include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
584
+        // Fields from hook
585
+        $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
586
+        $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
587
+        print $hookmanager->resPrint;
588
+        // Date creation
589
+        if (! empty($arrayfields['e.datec']['checked']))
590
+        {
591
+            print '<td align="center" class="nowrap">';
592
+            print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
593
+            print '</td>';
594
+            if (! $i) $totalarray['nbfield']++;
595
+        }
596
+        // Date modification
597
+        if (! empty($arrayfields['e.tms']['checked']))
598
+        {
599
+            print '<td align="center" class="nowrap">';
600
+            print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
601
+            print '</td>';
602
+            if (! $i) $totalarray['nbfield']++;
603
+        }
604
+        // Status
605
+        if (! empty($arrayfields['e.fk_statut']['checked']))
606
+        {
607
+            print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut,5).'</td>';
608
+            if (! $i) $totalarray['nbfield']++;
609
+        }
610
+        // Billed
611
+        if (! empty($arrayfields['e.billed']['checked']))
612
+        {
613
+            print '<td align="center">'.yn($obj->billed).'</td>';
614
+            if (! $i) $totalarray['nbfield']++;
615
+        }
616
+
617
+        // Action column
618
+        print '<td></td>';
619
+        if (! $i) $totalarray['nbfield']++;
620
+
621
+        print "</tr>\n";
622
+
623
+        $i++;
624
+    }
625
+
626
+    print "</table>";
627
+    print "</div>";
628
+    print '</form>';
629
+    $db->free($resql);
630 630
 }
631 631
 else
632 632
 {
633
-	dol_print_error($db);
633
+    dol_print_error($db);
634 634
 }
635 635
 
636 636
 // End of page
Please login to merge, or discard this patch.
Braces   +208 added lines, -71 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@  discard block
 block discarded – undo
38 38
 $socid=GETPOST('socid','int');
39 39
 // Security check
40 40
 $expeditionid = GETPOST('id','int');
41
-if ($user->societe_id) $socid=$user->societe_id;
41
+if ($user->societe_id) {
42
+    $socid=$user->societe_id;
43
+}
42 44
 $result = restrictedArea($user, 'expedition',$expeditionid,'');
43 45
 
44 46
 $diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id;
@@ -60,8 +62,12 @@  discard block
 block discarded – undo
60 62
 $sortfield = GETPOST('sortfield','alpha');
61 63
 $sortorder = GETPOST('sortorder','alpha');
62 64
 $page = GETPOST('page','int');
63
-if (! $sortfield) $sortfield="e.ref";
64
-if (! $sortorder) $sortorder="DESC";
65
+if (! $sortfield) {
66
+    $sortfield="e.ref";
67
+}
68
+if (! $sortorder) {
69
+    $sortorder="DESC";
70
+}
65 71
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
66 72
 $offset = $limit * $page;
67 73
 $pageprev = $page - 1;
@@ -85,7 +91,9 @@  discard block
 block discarded – undo
85 91
 	's.nom'=>"ThirdParty",
86 92
 	'e.note_public'=>'NotePublic',
87 93
 );
88
-if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate";
94
+if (empty($user->socid)) {
95
+    $fieldstosearchall["e.note_private"]="NotePrivate";
96
+}
89 97
 
90 98
 $checkedtypetiers=0;
91 99
 $arrayfields=array(
@@ -111,7 +119,9 @@  discard block
 block discarded – undo
111 119
 {
112 120
 	foreach($extrafields->attribute_label as $key => $val)
113 121
 	{
114
-		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]));
122
+		if (! empty($extrafields->attribute_list[$key])) {
123
+		    $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]));
124
+		}
115 125
 	}
116 126
 }
117 127
 
@@ -125,14 +135,18 @@  discard block
 block discarded – undo
125 135
 
126 136
 $parameters=array('socid'=>$socid);
127 137
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
128
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
138
+if ($reshook < 0) {
139
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140
+}
129 141
 
130 142
 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
131 143
 
132 144
 // Purge search criteria
133
-if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
145
+if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) {
146
+    // All tests are required to be compatible with all browsers
134 147
 {
135 148
 	$search_ref_exp='';
149
+}
136 150
 	$search_ref_liv='';
137 151
 	$search_ref_customer='';
138 152
 	$search_company='';
@@ -185,27 +199,35 @@  discard block
 block discarded – undo
185 199
 $sql.= " state.code_departement as state_code, state.nom as state_name,";
186 200
 $sql.= ' e.date_creation as date_creation, e.tms as date_update';
187 201
 // Add fields from extrafields
188
-foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
202
+foreach ($extrafields->attribute_label as $key => $val) {
203
+    $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
204
+}
189 205
 // Add fields from hooks
190 206
 $parameters=array();
191 207
 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
192 208
 $sql.=$hookmanager->resPrint;
193 209
 $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
194
-if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
210
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
211
+    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
212
+}
195 213
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
196 214
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
197 215
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
198 216
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
199 217
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
200 218
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
201
-if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
219
+if (!$user->rights->societe->client->voir && !$socid) {
220
+    // Internal user with no permission to see all
202 221
 {
203 222
 	$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
204 223
 }
224
+}
205 225
 $sql.= " WHERE e.entity IN (".getEntity('expedition').")";
206
-if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
226
+if (!$user->rights->societe->client->voir && !$socid) {
227
+    // Internal user with no permission to see all
207 228
 {
208 229
 	$sql.= " AND e.fk_soc = sc.fk_soc";
230
+}
209 231
 	$sql.= " AND sc.fk_user = " .$user->id;
210 232
 }
211 233
 if ($socid)
@@ -215,17 +237,39 @@  discard block
 block discarded – undo
215 237
 if ($viewstatut <> '' && $viewstatut >= 0) {
216 238
 	$sql.= " AND e.fk_statut = ".$viewstatut;
217 239
 }
218
-if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer);
219
-if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed;
220
-if ($search_town)  $sql.= natural_search('s.town', $search_town);
221
-if ($search_zip)   $sql.= natural_search("s.zip",$search_zip);
222
-if ($search_state) $sql.= natural_search("state.nom",$search_state);
223
-if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
224
-if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
225
-if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
226
-if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
227
-if ($search_company) $sql .= natural_search('s.nom', $search_company);
228
-if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
240
+if ($search_ref_customer != '') {
241
+    $sql.=natural_search('e.ref_customer', $search_ref_customer);
242
+}
243
+if ($search_billed != '' && $search_billed >= 0) {
244
+    $sql.=' AND e.billed = '.$search_billed;
245
+}
246
+if ($search_town) {
247
+    $sql.= natural_search('s.town', $search_town);
248
+}
249
+if ($search_zip) {
250
+    $sql.= natural_search("s.zip",$search_zip);
251
+}
252
+if ($search_state) {
253
+    $sql.= natural_search("state.nom",$search_state);
254
+}
255
+if ($search_country) {
256
+    $sql .= " AND s.fk_pays IN (".$search_country.')';
257
+}
258
+if ($search_type_thirdparty) {
259
+    $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
260
+}
261
+if ($search_ref_exp) {
262
+    $sql .= natural_search('e.ref', $search_ref_exp);
263
+}
264
+if ($search_ref_liv) {
265
+    $sql .= natural_search('l.ref', $search_ref_liv);
266
+}
267
+if ($search_company) {
268
+    $sql .= natural_search('s.nom', $search_company);
269
+}
270
+if ($sall) {
271
+    $sql .= natural_search(array_keys($fieldstosearchall), $sall);
272
+}
229 273
 
230 274
 // Add where from extra fields
231 275
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -242,9 +286,11 @@  discard block
 block discarded – undo
242 286
 {
243 287
 	$result = $db->query($sql);
244 288
 	$nbtotalofrecords = $db->num_rows($result);
245
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
289
+	if (($page * $limit) > $nbtotalofrecords) {
290
+	    // if total resultset is smaller then paging size (filtering), goto and load page 0
246 291
 	{
247 292
 		$page = 0;
293
+	}
248 294
 		$offset = 0;
249 295
 	}
250 296
 }
@@ -260,17 +306,39 @@  discard block
 block discarded – undo
260 306
 	$expedition = new Expedition($db);
261 307
 
262 308
 	$param='';
263
-	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
264
-	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
265
-	if ($sall) $param.= "&amp;sall=".urlencode($sall);
266
-	if ($search_ref_exp)  $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
267
-	if ($search_ref_liv)  $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
268
-	if ($search_ref_customer) $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
269
-	if ($search_company)   $param.= "&amp;search_company=".urlencode($search_company);
270
-	if ($search_town)      $param.= '&search_town='.urlencode($search_town);
271
-	if ($search_zip)       $param.= '&search_zip='.urlencode($search_zip);
272
-	if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut);
273
-	if ($optioncss != '')  $param.='&amp;optioncss='.urlencode($optioncss);
309
+	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
310
+	    $param.='&contextpage='.urlencode($contextpage);
311
+	}
312
+	if ($limit > 0 && $limit != $conf->liste_limit) {
313
+	    $param.='&limit='.urlencode($limit);
314
+	}
315
+	if ($sall) {
316
+	    $param.= "&amp;sall=".urlencode($sall);
317
+	}
318
+	if ($search_ref_exp) {
319
+	    $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
320
+	}
321
+	if ($search_ref_liv) {
322
+	    $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
323
+	}
324
+	if ($search_ref_customer) {
325
+	    $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
326
+	}
327
+	if ($search_company) {
328
+	    $param.= "&amp;search_company=".urlencode($search_company);
329
+	}
330
+	if ($search_town) {
331
+	    $param.= '&search_town='.urlencode($search_town);
332
+	}
333
+	if ($search_zip) {
334
+	    $param.= '&search_zip='.urlencode($search_zip);
335
+	}
336
+	if ($viewstatut != '') {
337
+	    $param.= '&viewstatut='.urlencode($viewstatut);
338
+	}
339
+	if ($optioncss != '') {
340
+	    $param.='&amp;optioncss='.urlencode($optioncss);
341
+	}
274 342
 	// Add $param from extra fields
275 343
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
276 344
 
@@ -286,7 +354,9 @@  discard block
 block discarded – undo
286 354
 
287 355
 	$i = 0;
288 356
 	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
289
-	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
357
+	if ($optioncss != '') {
358
+	    print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
359
+	}
290 360
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
291 361
 	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
292 362
 	print '<input type="hidden" name="action" value="list">';
@@ -298,7 +368,9 @@  discard block
 block discarded – undo
298 368
 
299 369
 	if ($sall)
300 370
 	{
301
-		foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
371
+		foreach($fieldstosearchall as $key => $val) {
372
+		    $fieldstosearchall[$key]=$langs->trans($val);
373
+		}
302 374
 		print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
303 375
 	}
304 376
 
@@ -343,9 +415,13 @@  discard block
 block discarded – undo
343 415
 		print '</td>';
344 416
 	}
345 417
 	// Town
346
-	if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
418
+	if (! empty($arrayfields['s.town']['checked'])) {
419
+	    print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
420
+	}
347 421
 	// Zip
348
-	if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
422
+	if (! empty($arrayfields['s.zip']['checked'])) {
423
+	    print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
424
+	}
349 425
 	// State
350 426
 	if (! empty($arrayfields['state.nom']['checked']))
351 427
 	{
@@ -425,17 +501,39 @@  discard block
 block discarded – undo
425 501
 	print "</tr>\n";
426 502
 
427 503
 	print '<tr class="liste_titre">';
428
-	if (! empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
429
-	if (! empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
430
-	if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
431
-	if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
432
-	if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
433
-	if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
434
-	if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
435
-	if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
436
-	if (! empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
437
-	if (! empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
438
-	if (! empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
504
+	if (! empty($arrayfields['e.ref']['checked'])) {
505
+	    print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
506
+	}
507
+	if (! empty($arrayfields['e.ref_customer']['checked'])) {
508
+	    print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
509
+	}
510
+	if (! empty($arrayfields['s.nom']['checked'])) {
511
+	    print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
512
+	}
513
+	if (! empty($arrayfields['s.town']['checked'])) {
514
+	    print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
515
+	}
516
+	if (! empty($arrayfields['s.zip']['checked'])) {
517
+	    print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
518
+	}
519
+	if (! empty($arrayfields['state.nom']['checked'])) {
520
+	    print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
521
+	}
522
+	if (! empty($arrayfields['country.code_iso']['checked'])) {
523
+	    print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
524
+	}
525
+	if (! empty($arrayfields['typent.code']['checked'])) {
526
+	    print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
527
+	}
528
+	if (! empty($arrayfields['e.date_delivery']['checked'])) {
529
+	    print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
530
+	}
531
+	if (! empty($arrayfields['l.ref']['checked'])) {
532
+	    print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
533
+	}
534
+	if (! empty($arrayfields['l.date_delivery']['checked'])) {
535
+	    print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
536
+	}
439 537
 	// Extra fields
440 538
 	if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
441 539
 	{
@@ -445,7 +543,9 @@  discard block
 block discarded – undo
445 543
 			{
446 544
 				$align=$extrafields->getAlignFlag($key);
447 545
 				$sortonfield = "ef.".$key;
448
-				if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
546
+				if (! empty($extrafields->attribute_computed[$key])) {
547
+				    $sortonfield='';
548
+				}
449 549
 				print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
450 550
 			}
451 551
 		}
@@ -454,10 +554,18 @@  discard block
 block discarded – undo
454 554
 	$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
455 555
 	$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
456 556
 	print $hookmanager->resPrint;
457
-	if (! empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
458
-	if (! empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
459
-	if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
460
-	if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
557
+	if (! empty($arrayfields['e.datec']['checked'])) {
558
+	    print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
559
+	}
560
+	if (! empty($arrayfields['e.tms']['checked'])) {
561
+	    print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
562
+	}
563
+	if (! empty($arrayfields['e.fk_statut']['checked'])) {
564
+	    print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
565
+	}
566
+	if (! empty($arrayfields['e.billed']['checked'])) {
567
+	    print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
568
+	}
461 569
 	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
462 570
 	print "</tr>\n";
463 571
 
@@ -483,7 +591,9 @@  discard block
 block discarded – undo
483 591
 			print "<td>";
484 592
 			print $shipment->getNomUrl(1);
485 593
 			print "</td>\n";
486
-			if (! $i) $totalarray['nbfield']++;
594
+			if (! $i) {
595
+			    $totalarray['nbfield']++;
596
+			}
487 597
 		}
488 598
 
489 599
 		// Ref customer
@@ -492,7 +602,9 @@  discard block
 block discarded – undo
492 602
 			print "<td>";
493 603
 			print $obj->ref_customer;
494 604
 			print "</td>\n";
495
-			if (! $i) $totalarray['nbfield']++;
605
+			if (! $i) {
606
+			    $totalarray['nbfield']++;
607
+			}
496 608
 		}
497 609
 
498 610
 		// Third party
@@ -501,7 +613,9 @@  discard block
 block discarded – undo
501 613
 			print '<td>';
502 614
 			print $companystatic->getNomUrl(1);
503 615
 			print '</td>';
504
-			if (! $i) $totalarray['nbfield']++;
616
+			if (! $i) {
617
+			    $totalarray['nbfield']++;
618
+			}
505 619
 		}
506 620
 		// Town
507 621
 		if (! empty($arrayfields['s.town']['checked']))
@@ -509,7 +623,9 @@  discard block
 block discarded – undo
509 623
 			print '<td class="nocellnopadd">';
510 624
 			print $obj->town;
511 625
 			print '</td>';
512
-			if (! $i) $totalarray['nbfield']++;
626
+			if (! $i) {
627
+			    $totalarray['nbfield']++;
628
+			}
513 629
 		}
514 630
 		// Zip
515 631
 		if (! empty($arrayfields['s.zip']['checked']))
@@ -517,13 +633,17 @@  discard block
 block discarded – undo
517 633
 			print '<td class="nocellnopadd">';
518 634
 			print $obj->zip;
519 635
 			print '</td>';
520
-			if (! $i) $totalarray['nbfield']++;
636
+			if (! $i) {
637
+			    $totalarray['nbfield']++;
638
+			}
521 639
 		}
522 640
 		// State
523 641
 		if (! empty($arrayfields['state.nom']['checked']))
524 642
 		{
525 643
 			print "<td>".$obj->state_name."</td>\n";
526
-			if (! $i) $totalarray['nbfield']++;
644
+			if (! $i) {
645
+			    $totalarray['nbfield']++;
646
+			}
527 647
 		}
528 648
 		// Country
529 649
 		if (! empty($arrayfields['country.code_iso']['checked']))
@@ -532,16 +652,22 @@  discard block
 block discarded – undo
532 652
 			$tmparray=getCountry($obj->fk_pays,'all');
533 653
 			print $tmparray['label'];
534 654
 			print '</td>';
535
-			if (! $i) $totalarray['nbfield']++;
655
+			if (! $i) {
656
+			    $totalarray['nbfield']++;
657
+			}
536 658
 		}
537 659
 		// Type ent
538 660
 		if (! empty($arrayfields['typent.code']['checked']))
539 661
 		{
540 662
 			print '<td align="center">';
541
-			if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
663
+			if (count($typenArray)==0) {
664
+			    $typenArray = $formcompany->typent_array(1);
665
+			}
542 666
 			print $typenArray[$obj->typent_code];
543 667
 			print '</td>';
544
-			if (! $i) $totalarray['nbfield']++;
668
+			if (! $i) {
669
+			    $totalarray['nbfield']++;
670
+			}
545 671
 		}
546 672
 
547 673
 		// Date delivery planed
@@ -560,7 +686,9 @@  discard block
 block discarded – undo
560 686
 		{
561 687
 			$shipment->fetchObjectLinked($shipment->id,$shipment->element);
562 688
 			$receiving='';
563
-			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']);
689
+			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) {
690
+			    $receiving=reset($shipment->linkedObjects['delivery']);
691
+			}
564 692
 
565 693
 			if (! empty($arrayfields['l.ref']['checked']))
566 694
 			{
@@ -591,7 +719,9 @@  discard block
 block discarded – undo
591 719
 			print '<td align="center" class="nowrap">';
592 720
 			print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
593 721
 			print '</td>';
594
-			if (! $i) $totalarray['nbfield']++;
722
+			if (! $i) {
723
+			    $totalarray['nbfield']++;
724
+			}
595 725
 		}
596 726
 		// Date modification
597 727
 		if (! empty($arrayfields['e.tms']['checked']))
@@ -599,24 +729,32 @@  discard block
 block discarded – undo
599 729
 			print '<td align="center" class="nowrap">';
600 730
 			print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
601 731
 			print '</td>';
602
-			if (! $i) $totalarray['nbfield']++;
732
+			if (! $i) {
733
+			    $totalarray['nbfield']++;
734
+			}
603 735
 		}
604 736
 		// Status
605 737
 		if (! empty($arrayfields['e.fk_statut']['checked']))
606 738
 		{
607 739
 			print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut,5).'</td>';
608
-			if (! $i) $totalarray['nbfield']++;
740
+			if (! $i) {
741
+			    $totalarray['nbfield']++;
742
+			}
609 743
 		}
610 744
 		// Billed
611 745
 		if (! empty($arrayfields['e.billed']['checked']))
612 746
 		{
613 747
 			print '<td align="center">'.yn($obj->billed).'</td>';
614
-			if (! $i) $totalarray['nbfield']++;
748
+			if (! $i) {
749
+			    $totalarray['nbfield']++;
750
+			}
615 751
 		}
616 752
 
617 753
 		// Action column
618 754
 		print '<td></td>';
619
-		if (! $i) $totalarray['nbfield']++;
755
+		if (! $i) {
756
+		    $totalarray['nbfield']++;
757
+		}
620 758
 
621 759
 		print "</tr>\n";
622 760
 
@@ -627,8 +765,7 @@  discard block
 block discarded – undo
627 765
 	print "</div>";
628 766
 	print '</form>';
629 767
 	$db->free($resql);
630
-}
631
-else
768
+} else
632 769
 {
633 770
 	dol_print_error($db);
634 771
 }
Please login to merge, or discard this patch.
Spacing   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -26,50 +26,50 @@  discard block
 block discarded – undo
26 26
 
27 27
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
28 28
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
29
-require DOL_BASE_PATH . '/main.inc.php';
30
-require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
29
+require DOL_BASE_PATH.'/main.inc.php';
30
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 33
 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
34 34
 
35 35
 // Load translation files required by the page
36
-$langs->loadLangs(array("sendings","deliveries",'companies','bills'));
36
+$langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills'));
37 37
 
38
-$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'shipmentlist';   // To manage different context of search
38
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search
39 39
 
40
-$socid=GETPOST('socid','int');
40
+$socid = GETPOST('socid', 'int');
41 41
 // Security check
42
-$expeditionid = GETPOST('id','int');
43
-if ($user->societe_id) $socid=$user->societe_id;
44
-$result = restrictedArea($user, 'expedition',$expeditionid,'');
42
+$expeditionid = GETPOST('id', 'int');
43
+if ($user->societe_id) $socid = $user->societe_id;
44
+$result = restrictedArea($user, 'expedition', $expeditionid, '');
45 45
 
46
-$diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id;
46
+$diroutputmassaction = $conf->expedition->dir_output.'/temp/massgeneration/'.$user->id;
47 47
 
48 48
 $search_ref_exp = GETPOST("search_ref_exp", 'alpha');
49 49
 $search_ref_liv = GETPOST('search_ref_liv', 'alpha');
50 50
 $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
51 51
 $search_company = GETPOST("search_company", 'alpha');
52
-$search_town=GETPOST('search_town','alpha');
53
-$search_zip=GETPOST('search_zip','alpha');
54
-$search_state=trim(GETPOST("search_state"));
55
-$search_country=GETPOST("search_country",'int');
56
-$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
57
-$search_billed=GETPOST("search_billed",'int');
58
-$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
59
-$optioncss = GETPOST('optioncss','alpha');
60
-
61
-$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
62
-$sortfield = GETPOST('sortfield','alpha');
63
-$sortorder = GETPOST('sortorder','alpha');
64
-$page = GETPOST('page','int');
65
-if (! $sortfield) $sortfield="e.ref";
66
-if (! $sortorder) $sortorder="DESC";
52
+$search_town = GETPOST('search_town', 'alpha');
53
+$search_zip = GETPOST('search_zip', 'alpha');
54
+$search_state = trim(GETPOST("search_state"));
55
+$search_country = GETPOST("search_country", 'int');
56
+$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
57
+$search_billed = GETPOST("search_billed", 'int');
58
+$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
59
+$optioncss = GETPOST('optioncss', 'alpha');
60
+
61
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
62
+$sortfield = GETPOST('sortfield', 'alpha');
63
+$sortorder = GETPOST('sortorder', 'alpha');
64
+$page = GETPOST('page', 'int');
65
+if (!$sortfield) $sortfield = "e.ref";
66
+if (!$sortorder) $sortorder = "DESC";
67 67
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
68 68
 $offset = $limit * $page;
69 69
 $pageprev = $page - 1;
70 70
 $pagenext = $page + 1;
71 71
 
72
-$viewstatut=GETPOST('viewstatut');
72
+$viewstatut = GETPOST('viewstatut');
73 73
 
74 74
 $object = new Expedition($db);
75 75
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 // fetch optionals attributes and labels
81 81
 $extralabels = $extrafields->fetch_name_optionals_label('expedition');
82
-$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
82
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
83 83
 
84 84
 // List of fields to search into when doing a "search in all"
85 85
 $fieldstosearchall = array(
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	's.nom'=>"ThirdParty",
88 88
 	'e.note_public'=>'NotePublic',
89 89
 );
90
-if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate";
90
+if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate";
91 91
 
92
-$checkedtypetiers=0;
93
-$arrayfields=array(
92
+$checkedtypetiers = 0;
93
+$arrayfields = array(
94 94
 	'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
95 95
 	'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
96 96
 	's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
104 104
 	'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
105 105
 	'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
106
-	'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
107
-	'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
106
+	'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)),
107
+	'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)),
108 108
 	'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
109 109
 );
110 110
 
111 111
 // Extra fields
112 112
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
113 113
 {
114
-	foreach($extrafields->attribute_label as $key => $val)
114
+	foreach ($extrafields->attribute_label as $key => $val)
115 115
 	{
116
-		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]));
116
+		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]));
117 117
 	}
118 118
 }
119 119
 
@@ -122,46 +122,46 @@  discard block
 block discarded – undo
122 122
  * Actions
123 123
  */
124 124
 
125
-if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
126
-if (! GETPOST('confirmmassaction','alpha')) { $massaction=''; }
125
+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
126
+if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
127 127
 
128
-$parameters=array('socid'=>$socid);
129
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
128
+$parameters = array('socid'=>$socid);
129
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
130 130
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131 131
 
132 132
 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
133 133
 
134 134
 // Purge search criteria
135
-if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
135
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
136 136
 {
137
-	$search_ref_exp='';
138
-	$search_ref_liv='';
139
-	$search_ref_customer='';
140
-	$search_company='';
141
-	$search_town='';
142
-	$search_zip="";
143
-	$search_state="";
144
-	$search_type='';
145
-	$search_country='';
146
-	$search_type_thirdparty='';
147
-	$search_billed='';
148
-	$viewstatut='';
149
-	$search_array_options=array();
137
+	$search_ref_exp = '';
138
+	$search_ref_liv = '';
139
+	$search_ref_customer = '';
140
+	$search_company = '';
141
+	$search_town = '';
142
+	$search_zip = "";
143
+	$search_state = "";
144
+	$search_type = '';
145
+	$search_country = '';
146
+	$search_type_thirdparty = '';
147
+	$search_billed = '';
148
+	$viewstatut = '';
149
+	$search_array_options = array();
150 150
 }
151 151
 
152 152
 if (empty($reshook))
153 153
 {
154 154
 	// Mass actions. Controls on number of lines checked
155
-	$maxformassaction=1000;
156
-	$numtoselect = (is_array($toselect)?count($toselect):0);
157
-	if (! empty($massaction) && $numtoselect < 1)
155
+	$maxformassaction = 1000;
156
+	$numtoselect = (is_array($toselect) ?count($toselect) : 0);
157
+	if (!empty($massaction) && $numtoselect < 1)
158 158
 	{
159 159
 		$error++;
160 160
 		setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
161 161
 	}
162
-	if (! $error && $numtoselect > $maxformassaction)
162
+	if (!$error && $numtoselect > $maxformassaction)
163 163
 	{
164
-		setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
164
+		setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
165 165
 		$error++;
166 166
 	}
167 167
 }
@@ -173,55 +173,55 @@  discard block
 block discarded – undo
173 173
  * View
174 174
  */
175 175
 
176
-$form=new Form($db);
177
-$companystatic=new Societe($db);
178
-$shipment=new Expedition($db);
179
-$formcompany=new FormCompany($db);
176
+$form = new Form($db);
177
+$companystatic = new Societe($db);
178
+$shipment = new Expedition($db);
179
+$formcompany = new FormCompany($db);
180 180
 
181
-$helpurl='EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
182
-llxHeader('',$langs->trans('ListOfSendings'),$helpurl);
181
+$helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
182
+llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
183 183
 
184 184
 $sql = "SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,";
185
-$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
186
-$sql.= " typent.code as typent_code,";
187
-$sql.= " state.code_departement as state_code, state.nom as state_name,";
188
-$sql.= ' e.date_creation as date_creation, e.tms as date_update';
185
+$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
186
+$sql .= " typent.code as typent_code,";
187
+$sql .= " state.code_departement as state_code, state.nom as state_name,";
188
+$sql .= ' e.date_creation as date_creation, e.tms as date_update';
189 189
 // Add fields from extrafields
190
-foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
190
+foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
191 191
 // Add fields from hooks
192
-$parameters=array();
193
-$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
194
-$sql.=$hookmanager->resPrint;
195
-$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
196
-if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
197
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
198
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
199
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
200
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
201
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
202
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
192
+$parameters = array();
193
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
194
+$sql .= $hookmanager->resPrint;
195
+$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
196
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
197
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
198
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
199
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
200
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
201
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
202
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
203 203
 if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
204 204
 {
205
-	$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
205
+	$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
206 206
 }
207
-$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
207
+$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
208 208
 if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
209 209
 {
210
-	$sql.= " AND e.fk_soc = sc.fk_soc";
211
-	$sql.= " AND sc.fk_user = " .$user->id;
210
+	$sql .= " AND e.fk_soc = sc.fk_soc";
211
+	$sql .= " AND sc.fk_user = ".$user->id;
212 212
 }
213 213
 if ($socid)
214 214
 {
215
-	$sql.= " AND e.fk_soc = ".$socid;
215
+	$sql .= " AND e.fk_soc = ".$socid;
216 216
 }
217 217
 if ($viewstatut <> '' && $viewstatut >= 0) {
218
-	$sql.= " AND e.fk_statut = ".$viewstatut;
218
+	$sql .= " AND e.fk_statut = ".$viewstatut;
219 219
 }
220
-if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer);
221
-if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed;
222
-if ($search_town)  $sql.= natural_search('s.town', $search_town);
223
-if ($search_zip)   $sql.= natural_search("s.zip",$search_zip);
224
-if ($search_state) $sql.= natural_search("state.nom",$search_state);
220
+if ($search_ref_customer != '') $sql .= natural_search('e.ref_customer', $search_ref_customer);
221
+if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed;
222
+if ($search_town)  $sql .= natural_search('s.town', $search_town);
223
+if ($search_zip)   $sql .= natural_search("s.zip", $search_zip);
224
+if ($search_state) $sql .= natural_search("state.nom", $search_state);
225 225
 if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
226 226
 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
227 227
 if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
234 234
 
235 235
 // Add where from hooks
236
-$parameters=array();
237
-$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
238
-$sql.=$hookmanager->resPrint;
236
+$parameters = array();
237
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
238
+$sql .= $hookmanager->resPrint;
239 239
 
240
-$sql.= $db->order($sortfield,$sortorder);
240
+$sql .= $db->order($sortfield, $sortorder);
241 241
 
242 242
 $nbtotalofrecords = '';
243 243
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -251,39 +251,39 @@  discard block
 block discarded – undo
251 251
 	}
252 252
 }
253 253
 
254
-$sql.= $db->plimit($limit + 1,$offset);
254
+$sql .= $db->plimit($limit + 1, $offset);
255 255
 
256 256
 //print $sql;
257
-$resql=$db->query($sql);
257
+$resql = $db->query($sql);
258 258
 if ($resql)
259 259
 {
260 260
 	$num = $db->num_rows($resql);
261 261
 
262 262
 	$expedition = new Expedition($db);
263 263
 
264
-	$param='';
265
-	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
266
-	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
267
-	if ($sall) $param.= "&amp;sall=".urlencode($sall);
268
-	if ($search_ref_exp)  $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
269
-	if ($search_ref_liv)  $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
270
-	if ($search_ref_customer) $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
271
-	if ($search_company)   $param.= "&amp;search_company=".urlencode($search_company);
272
-	if ($search_town)      $param.= '&search_town='.urlencode($search_town);
273
-	if ($search_zip)       $param.= '&search_zip='.urlencode($search_zip);
274
-	if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut);
275
-	if ($optioncss != '')  $param.='&amp;optioncss='.urlencode($optioncss);
264
+	$param = '';
265
+	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
266
+	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
267
+	if ($sall) $param .= "&amp;sall=".urlencode($sall);
268
+	if ($search_ref_exp)  $param .= "&amp;search_ref_exp=".urlencode($search_ref_exp);
269
+	if ($search_ref_liv)  $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv);
270
+	if ($search_ref_customer) $param .= "&amp;search_ref_customer=".urlencode($search_ref_customer);
271
+	if ($search_company)   $param .= "&amp;search_company=".urlencode($search_company);
272
+	if ($search_town)      $param .= '&search_town='.urlencode($search_town);
273
+	if ($search_zip)       $param .= '&search_zip='.urlencode($search_zip);
274
+	if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut);
275
+	if ($optioncss != '')  $param .= '&amp;optioncss='.urlencode($optioncss);
276 276
 	// Add $param from extra fields
277 277
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
278 278
 
279 279
 	//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
280 280
 
281
-	$newcardbutton='';
281
+	$newcardbutton = '';
282 282
 	if ($user->rights->expedition->creer)
283 283
 	{
284
-		$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
285
-		$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
286
-		$newcardbutton.= '</a>';
284
+		$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
285
+		$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
286
+		$newcardbutton .= '</a>';
287 287
 	}
288 288
 
289 289
 	$i = 0;
@@ -296,92 +296,92 @@  discard block
 block discarded – undo
296 296
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
297 297
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
298 298
 
299
-	print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
299
+	print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
300 300
 
301 301
 	if ($sall)
302 302
 	{
303
-		foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
304
-		print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
303
+		foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
304
+		print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
305 305
 	}
306 306
 
307
-	$moreforfilter='';
308
-	if (! empty($moreforfilter))
307
+	$moreforfilter = '';
308
+	if (!empty($moreforfilter))
309 309
 	{
310 310
 		print '<div class="liste_titre liste_titre_bydiv centpercent">';
311 311
 		print $moreforfilter;
312
-		$parameters=array('type'=>$type);
313
-		$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
312
+		$parameters = array('type'=>$type);
313
+		$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
314 314
 		print $hookmanager->resPrint;
315 315
 		print '</div>';
316 316
 	}
317 317
 
318
-	$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
319
-	$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
318
+	$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
319
+	$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
320 320
 
321 321
 	print '<div class="div-table-responsive">';
322
-	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
322
+	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
323 323
 
324 324
 	// Lignes des champs de filtre
325 325
 	print '<tr class="liste_titre_filter">';
326 326
 	// Ref
327
-	if (! empty($arrayfields['e.ref']['checked']))
327
+	if (!empty($arrayfields['e.ref']['checked']))
328 328
 	{
329 329
 		print '<td class="liste_titre">';
330 330
 		print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
331 331
 		print '</td>';
332 332
 	}
333 333
 	// Ref customer
334
-	if (! empty($arrayfields['e.ref_customer']['checked']))
334
+	if (!empty($arrayfields['e.ref_customer']['checked']))
335 335
 	{
336 336
 		print '<td class="liste_titre">';
337 337
 		print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
338 338
 		print '</td>';
339 339
 	}
340 340
 	// Thirdparty
341
-	if (! empty($arrayfields['s.nom']['checked']))
341
+	if (!empty($arrayfields['s.nom']['checked']))
342 342
 	{
343 343
 		print '<td class="liste_titre" align="left">';
344 344
 		print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
345 345
 		print '</td>';
346 346
 	}
347 347
 	// Town
348
-	if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
348
+	if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
349 349
 	// Zip
350
-	if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
350
+	if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
351 351
 	// State
352
-	if (! empty($arrayfields['state.nom']['checked']))
352
+	if (!empty($arrayfields['state.nom']['checked']))
353 353
 	{
354 354
 		print '<td class="liste_titre">';
355 355
 		print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
356 356
 		print '</td>';
357 357
 	}
358 358
 	// Country
359
-	if (! empty($arrayfields['country.code_iso']['checked']))
359
+	if (!empty($arrayfields['country.code_iso']['checked']))
360 360
 	{
361 361
 		print '<td class="liste_titre" align="center">';
362
-		print $form->select_country($search_country,'search_country','',0,'maxwidth100');
362
+		print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100');
363 363
 		print '</td>';
364 364
 	}
365 365
 	// Company type
366
-	if (! empty($arrayfields['typent.code']['checked']))
366
+	if (!empty($arrayfields['typent.code']['checked']))
367 367
 	{
368 368
 		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
369
-		print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
369
+		print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
370 370
 		print '</td>';
371 371
 	}
372 372
 	// Date delivery planned
373
-	if (! empty($arrayfields['e.date_delivery']['checked']))
373
+	if (!empty($arrayfields['e.date_delivery']['checked']))
374 374
 	{
375 375
 		print '<td class="liste_titre">&nbsp;</td>';
376 376
 	}
377
-	if (! empty($arrayfields['l.ref']['checked']))
377
+	if (!empty($arrayfields['l.ref']['checked']))
378 378
 	{
379 379
 		// Delivery ref
380 380
 		print '<td class="liste_titre">';
381 381
 		print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
382 382
 		print '</td>';
383 383
 	}
384
-	if (! empty($arrayfields['l.date_delivery']['checked']))
384
+	if (!empty($arrayfields['l.date_delivery']['checked']))
385 385
 	{
386 386
 		// Date received
387 387
 		print '<td class="liste_titre">&nbsp;</td>';
@@ -390,30 +390,30 @@  discard block
 block discarded – undo
390 390
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
391 391
 
392 392
 	// Fields from hook
393
-	$parameters=array('arrayfields'=>$arrayfields);
394
-	$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
393
+	$parameters = array('arrayfields'=>$arrayfields);
394
+	$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
395 395
 	print $hookmanager->resPrint;
396 396
 	// Date creation
397
-	if (! empty($arrayfields['e.datec']['checked']))
397
+	if (!empty($arrayfields['e.datec']['checked']))
398 398
 	{
399 399
 		print '<td class="liste_titre">';
400 400
 		print '</td>';
401 401
 	}
402 402
 	// Date modification
403
-	if (! empty($arrayfields['e.tms']['checked']))
403
+	if (!empty($arrayfields['e.tms']['checked']))
404 404
 	{
405 405
 		print '<td class="liste_titre">';
406 406
 		print '</td>';
407 407
 	}
408 408
 	// Status
409
-	if (! empty($arrayfields['e.fk_statut']['checked']))
409
+	if (!empty($arrayfields['e.fk_statut']['checked']))
410 410
 	{
411 411
 		print '<td class="liste_titre maxwidthonsmartphone" align="right">';
412
-		print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')),$viewstatut,1);
412
+		print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $viewstatut, 1);
413 413
 		print '</td>';
414 414
 	}
415 415
 	// Status billed
416
-	if (! empty($arrayfields['e.billed']['checked']))
416
+	if (!empty($arrayfields['e.billed']['checked']))
417 417
 	{
418 418
 		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
419 419
 		print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
@@ -421,136 +421,136 @@  discard block
 block discarded – undo
421 421
 	}
422 422
 	// Action column
423 423
 	print '<td class="liste_titre" align="middle">';
424
-	$searchpicto=$form->showFilterAndCheckAddButtons(0);
424
+	$searchpicto = $form->showFilterAndCheckAddButtons(0);
425 425
 	print $searchpicto;
426 426
 	print '</td>';
427 427
 	print "</tr>\n";
428 428
 
429 429
 	print '<tr class="liste_titre">';
430
-	if (! empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
431
-	if (! empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
432
-	if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
433
-	if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
434
-	if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
435
-	if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
436
-	if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
437
-	if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
438
-	if (! empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
439
-	if (! empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
440
-	if (! empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
430
+	if (!empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
431
+	if (!empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder);
432
+	if (!empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, 'align="left"', $sortfield, $sortorder);
433
+	if (!empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
434
+	if (!empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
435
+	if (!empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
436
+	if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
437
+	if (!empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
438
+	if (!empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, 'align="center"', $sortfield, $sortorder);
439
+	if (!empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
440
+	if (!empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, 'align="center"', $sortfield, $sortorder);
441 441
 	// Extra fields
442 442
 	if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
443 443
 	{
444
-		foreach($extrafields->attribute_label as $key => $val)
444
+		foreach ($extrafields->attribute_label as $key => $val)
445 445
 		{
446
-			if (! empty($arrayfields["ef.".$key]['checked']))
446
+			if (!empty($arrayfields["ef.".$key]['checked']))
447 447
 			{
448
-				$align=$extrafields->getAlignFlag($key);
448
+				$align = $extrafields->getAlignFlag($key);
449 449
 				$sortonfield = "ef.".$key;
450
-				if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
451
-				print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
450
+				if (!empty($extrafields->attribute_computed[$key])) $sortonfield = '';
451
+				print_liste_field_titre($extralabels[$key], $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder);
452 452
 			}
453 453
 		}
454 454
 	}
455 455
 	// Hook fields
456
-	$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
457
-	$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
456
+	$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
457
+	$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
458 458
 	print $hookmanager->resPrint;
459
-	if (! empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
460
-	if (! empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
461
-	if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
462
-	if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
463
-	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
459
+	if (!empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
460
+	if (!empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
461
+	if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder);
462
+	if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, 'align="center"', $sortfield, $sortorder);
463
+	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
464 464
 	print "</tr>\n";
465 465
 
466
-	$i=0;
467
-	$totalarray=array();
468
-	while ($i < min($num,$limit))
466
+	$i = 0;
467
+	$totalarray = array();
468
+	while ($i < min($num, $limit))
469 469
 	{
470 470
 		$obj = $db->fetch_object($resql);
471 471
 
472
-		$shipment->id=$obj->rowid;
473
-		$shipment->ref=$obj->ref;
472
+		$shipment->id = $obj->rowid;
473
+		$shipment->ref = $obj->ref;
474 474
 
475
-		$companystatic->id=$obj->socid;
476
-		$companystatic->ref=$obj->name;
477
-		$companystatic->name=$obj->name;
475
+		$companystatic->id = $obj->socid;
476
+		$companystatic->ref = $obj->name;
477
+		$companystatic->name = $obj->name;
478 478
 
479 479
 
480 480
 		print '<tr class="oddeven">';
481 481
 
482 482
 		// Ref
483
-		if (! empty($arrayfields['e.ref']['checked']))
483
+		if (!empty($arrayfields['e.ref']['checked']))
484 484
 		{
485 485
 			print "<td>";
486 486
 			print $shipment->getNomUrl(1);
487 487
 			print "</td>\n";
488
-			if (! $i) $totalarray['nbfield']++;
488
+			if (!$i) $totalarray['nbfield']++;
489 489
 		}
490 490
 
491 491
 		// Ref customer
492
-		if (! empty($arrayfields['e.ref_customer']['checked']))
492
+		if (!empty($arrayfields['e.ref_customer']['checked']))
493 493
 		{
494 494
 			print "<td>";
495 495
 			print $obj->ref_customer;
496 496
 			print "</td>\n";
497
-			if (! $i) $totalarray['nbfield']++;
497
+			if (!$i) $totalarray['nbfield']++;
498 498
 		}
499 499
 
500 500
 		// Third party
501
-		if (! empty($arrayfields['s.nom']['checked']))
501
+		if (!empty($arrayfields['s.nom']['checked']))
502 502
 		{
503 503
 			print '<td>';
504 504
 			print $companystatic->getNomUrl(1);
505 505
 			print '</td>';
506
-			if (! $i) $totalarray['nbfield']++;
506
+			if (!$i) $totalarray['nbfield']++;
507 507
 		}
508 508
 		// Town
509
-		if (! empty($arrayfields['s.town']['checked']))
509
+		if (!empty($arrayfields['s.town']['checked']))
510 510
 		{
511 511
 			print '<td class="nocellnopadd">';
512 512
 			print $obj->town;
513 513
 			print '</td>';
514
-			if (! $i) $totalarray['nbfield']++;
514
+			if (!$i) $totalarray['nbfield']++;
515 515
 		}
516 516
 		// Zip
517
-		if (! empty($arrayfields['s.zip']['checked']))
517
+		if (!empty($arrayfields['s.zip']['checked']))
518 518
 		{
519 519
 			print '<td class="nocellnopadd">';
520 520
 			print $obj->zip;
521 521
 			print '</td>';
522
-			if (! $i) $totalarray['nbfield']++;
522
+			if (!$i) $totalarray['nbfield']++;
523 523
 		}
524 524
 		// State
525
-		if (! empty($arrayfields['state.nom']['checked']))
525
+		if (!empty($arrayfields['state.nom']['checked']))
526 526
 		{
527 527
 			print "<td>".$obj->state_name."</td>\n";
528
-			if (! $i) $totalarray['nbfield']++;
528
+			if (!$i) $totalarray['nbfield']++;
529 529
 		}
530 530
 		// Country
531
-		if (! empty($arrayfields['country.code_iso']['checked']))
531
+		if (!empty($arrayfields['country.code_iso']['checked']))
532 532
 		{
533 533
 			print '<td align="center">';
534
-			$tmparray=getCountry($obj->fk_pays,'all');
534
+			$tmparray = getCountry($obj->fk_pays, 'all');
535 535
 			print $tmparray['label'];
536 536
 			print '</td>';
537
-			if (! $i) $totalarray['nbfield']++;
537
+			if (!$i) $totalarray['nbfield']++;
538 538
 		}
539 539
 		// Type ent
540
-		if (! empty($arrayfields['typent.code']['checked']))
540
+		if (!empty($arrayfields['typent.code']['checked']))
541 541
 		{
542 542
 			print '<td align="center">';
543
-			if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
543
+			if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
544 544
 			print $typenArray[$obj->typent_code];
545 545
 			print '</td>';
546
-			if (! $i) $totalarray['nbfield']++;
546
+			if (!$i) $totalarray['nbfield']++;
547 547
 		}
548 548
 
549 549
 		// Date delivery planed
550
-		if (! empty($arrayfields['e.date_delivery']['checked']))
550
+		if (!empty($arrayfields['e.date_delivery']['checked']))
551 551
 		{
552 552
 			print '<td align="center">';
553
-			print dol_print_date($db->jdate($obj->date_livraison),"day");
553
+			print dol_print_date($db->jdate($obj->date_livraison), "day");
554 554
 			/*$now = time();
555 555
     		if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
556 556
     		{
@@ -558,13 +558,13 @@  discard block
 block discarded – undo
558 558
 			print "</td>\n";
559 559
 		}
560 560
 
561
-		if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked']))
561
+		if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked']))
562 562
 		{
563
-			$shipment->fetchObjectLinked($shipment->id,$shipment->element);
564
-			$receiving='';
565
-			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']);
563
+			$shipment->fetchObjectLinked($shipment->id, $shipment->element);
564
+			$receiving = '';
565
+			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving = reset($shipment->linkedObjects['delivery']);
566 566
 
567
-			if (! empty($arrayfields['l.ref']['checked']))
567
+			if (!empty($arrayfields['l.ref']['checked']))
568 568
 			{
569 569
 				// Ref
570 570
 				print '<td>';
@@ -572,11 +572,11 @@  discard block
 block discarded – undo
572 572
 				print '</td>';
573 573
 			}
574 574
 
575
-			if (! empty($arrayfields['l.date_delivery']['checked']))
575
+			if (!empty($arrayfields['l.date_delivery']['checked']))
576 576
 			{
577 577
 				// Date received
578 578
 				print '<td align="center">';
579
-				print dol_print_date($db->jdate($obj->date_reception),"day");
579
+				print dol_print_date($db->jdate($obj->date_reception), "day");
580 580
 				print '</td>'."\n";
581 581
 			}
582 582
 		}
@@ -584,41 +584,41 @@  discard block
 block discarded – undo
584 584
 		// Extra fields
585 585
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
586 586
 		// Fields from hook
587
-		$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
588
-		$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
587
+		$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
588
+		$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
589 589
 		print $hookmanager->resPrint;
590 590
 		// Date creation
591
-		if (! empty($arrayfields['e.datec']['checked']))
591
+		if (!empty($arrayfields['e.datec']['checked']))
592 592
 		{
593 593
 			print '<td align="center" class="nowrap">';
594 594
 			print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
595 595
 			print '</td>';
596
-			if (! $i) $totalarray['nbfield']++;
596
+			if (!$i) $totalarray['nbfield']++;
597 597
 		}
598 598
 		// Date modification
599
-		if (! empty($arrayfields['e.tms']['checked']))
599
+		if (!empty($arrayfields['e.tms']['checked']))
600 600
 		{
601 601
 			print '<td align="center" class="nowrap">';
602 602
 			print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
603 603
 			print '</td>';
604
-			if (! $i) $totalarray['nbfield']++;
604
+			if (!$i) $totalarray['nbfield']++;
605 605
 		}
606 606
 		// Status
607
-		if (! empty($arrayfields['e.fk_statut']['checked']))
607
+		if (!empty($arrayfields['e.fk_statut']['checked']))
608 608
 		{
609
-			print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut,5).'</td>';
610
-			if (! $i) $totalarray['nbfield']++;
609
+			print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>';
610
+			if (!$i) $totalarray['nbfield']++;
611 611
 		}
612 612
 		// Billed
613
-		if (! empty($arrayfields['e.billed']['checked']))
613
+		if (!empty($arrayfields['e.billed']['checked']))
614 614
 		{
615 615
 			print '<td align="center">'.yn($obj->billed).'</td>';
616
-			if (! $i) $totalarray['nbfield']++;
616
+			if (!$i) $totalarray['nbfield']++;
617 617
 		}
618 618
 
619 619
 		// Action column
620 620
 		print '<td></td>';
621
-		if (! $i) $totalarray['nbfield']++;
621
+		if (!$i) $totalarray['nbfield']++;
622 622
 
623 623
 		print "</tr>\n";
624 624
 
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/stats/month.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@
 block discarded – undo
61 61
     $px->SetHeight($HEIGHT);
62 62
     $px->SetYLabel($langs->trans("NbOfOrders"));
63 63
     $px->SetShading(3);
64
-	$px->SetHorizTickIncrement(1);
65
-	$px->SetPrecisionY(0);
64
+    $px->SetHorizTickIncrement(1);
65
+    $px->SetPrecisionY(0);
66 66
     $px->draw($filename,$fileurl);
67 67
 }
68 68
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
26 26
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
27
-require DOL_BASE_PATH . '/main.inc.php';
28
-require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
27
+require DOL_BASE_PATH.'/main.inc.php';
28
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
31 31
 
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 
39 39
 llxHeader();
40 40
 
41
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
42
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
41
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
42
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
43 43
 
44 44
 $mesg = '';
45 45
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 $px = new DolGraph();
57 57
 $mesg = $px->isGraphKo();
58
-if (! $mesg)
58
+if (!$mesg)
59 59
 {
60 60
     $px->SetData($data);
61 61
     $px->SetMaxValue($px->GetCeilMaxValue());
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     $px->SetShading(3);
66 66
 	$px->SetHorizTickIncrement(1);
67 67
 	$px->SetPrecisionY(0);
68
-    $px->draw($filename,$fileurl);
68
+    $px->draw($filename, $fileurl);
69 69
 }
70 70
 
71 71
 print '<table class="border" width="100%">';
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/stats/index.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 $data = $stats->getAllByYear();
206 206
 $arrayyears=array();
207 207
 foreach($data as $val) {
208
-	if (! empty($val['year'])) {
209
-		$arrayyears[$val['year']]=$val['year'];
210
-	}
208
+    if (! empty($val['year'])) {
209
+        $arrayyears[$val['year']]=$val['year'];
210
+    }
211 211
 }
212 212
 if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
213 213
 
@@ -230,33 +230,33 @@  discard block
 block discarded – undo
230 230
 
231 231
 //if (empty($socid))
232 232
 //{
233
-	// Show filter box
234
-	print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
235
-	print '<input type="hidden" name="mode" value="'.$mode.'">';
236
-
237
-	print '<table class="noborder" width="100%">';
238
-	print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
239
-	// Company
240
-	print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
241
-	if ($mode == 'customer') $filter='s.client in (1,2,3)';
242
-	if ($mode == 'supplier') $filter='s.fournisseur = 1';
243
-	print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
244
-	print '</td></tr>';
245
-	// User
246
-	print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
247
-	print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
248
-	print '</td></tr>';
249
-	// Year
250
-	print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
251
-	if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
252
-	if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
253
-	arsort($arrayyears);
254
-	print $form->selectarray('year',$arrayyears,$year,0);
255
-	print '</td></tr>';
256
-	print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
257
-	print '</table>';
258
-	print '</form>';
259
-	print '<br><br>';
233
+    // Show filter box
234
+    print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
235
+    print '<input type="hidden" name="mode" value="'.$mode.'">';
236
+
237
+    print '<table class="noborder" width="100%">';
238
+    print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
239
+    // Company
240
+    print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
241
+    if ($mode == 'customer') $filter='s.client in (1,2,3)';
242
+    if ($mode == 'supplier') $filter='s.fournisseur = 1';
243
+    print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
244
+    print '</td></tr>';
245
+    // User
246
+    print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
247
+    print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
248
+    print '</td></tr>';
249
+    // Year
250
+    print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
251
+    if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
252
+    if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
253
+    arsort($arrayyears);
254
+    print $form->selectarray('year',$arrayyears,$year,0);
255
+    print '</td></tr>';
256
+    print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
257
+    print '</table>';
258
+    print '</form>';
259
+    print '<br><br>';
260 260
 //}
261 261
 
262 262
 
@@ -272,31 +272,31 @@  discard block
 block discarded – undo
272 272
 $oldyear=0;
273 273
 foreach ($data as $val)
274 274
 {
275
-	$year = $val['year'];
276
-	while (! empty($year) && $oldyear > $year+1)
277
-	{ // If we have empty year
278
-		$oldyear--;
275
+    $year = $val['year'];
276
+    while (! empty($year) && $oldyear > $year+1)
277
+    { // If we have empty year
278
+        $oldyear--;
279 279
 
280 280
 
281
-		print '<tr class="oddeven" height="24">';
282
-		print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.'">'.$oldyear.'</a></td>';
281
+        print '<tr class="oddeven" height="24">';
282
+        print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.'">'.$oldyear.'</a></td>';
283 283
 
284
-		print '<td align="right">0</td>';
285
-		/*print '<td align="right">0</td>';
284
+        print '<td align="right">0</td>';
285
+        /*print '<td align="right">0</td>';
286 286
 		print '<td align="right">0</td>';*/
287
-		print '</tr>';
288
-	}
289
-
290
-	print '<tr class="oddeven" height="24">';
291
-	print '<td align="center">';
292
-	if ($year) print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a>';
293
-	else print $langs->trans("ValidationDateNotDefinedEvenIfShipmentValidated");
294
-	print '</td>';
295
-	print '<td align="right">'.$val['nb'].'</td>';
296
-	/*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
287
+        print '</tr>';
288
+    }
289
+
290
+    print '<tr class="oddeven" height="24">';
291
+    print '<td align="center">';
292
+    if ($year) print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a>';
293
+    else print $langs->trans("ValidationDateNotDefinedEvenIfShipmentValidated");
294
+    print '</td>';
295
+    print '<td align="right">'.$val['nb'].'</td>';
296
+    /*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
297 297
 	print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';*/
298
-	print '</tr>';
299
-	$oldyear=$year;
298
+    print '</tr>';
299
+    $oldyear=$year;
300 300
 }
301 301
 
302 302
 print '</table>';
Please login to merge, or discard this patch.
Braces   +35 added lines, -16 removed lines patch added patch discarded remove patch
@@ -74,15 +74,22 @@  discard block
 block discarded – undo
74 74
 if (!$user->rights->societe->client->voir || $user->societe_id)
75 75
 {
76 76
     $filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
77
-    if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
78
-    if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
79
-}
80
-else
77
+    if ($mode == 'customer') {
78
+        $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
79
+    }
80
+    if ($mode == 'supplier') {
81
+        $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
82
+    }
83
+    } else
81 84
 {
82 85
     $filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
83
-    if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$year.'.png';
84
-    if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$year.'.png';
85
-}
86
+    if ($mode == 'customer') {
87
+        $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$year.'.png';
88
+    }
89
+    if ($mode == 'supplier') {
90
+        $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$year.'.png';
91
+    }
92
+    }
86 93
 
87 94
 $px1 = new DolGraph();
88 95
 $mesg = $px1->isGraphKo();
@@ -209,7 +216,9 @@  discard block
 block discarded – undo
209 216
 		$arrayyears[$val['year']]=$val['year'];
210 217
 	}
211 218
 }
212
-if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
219
+if (! count($arrayyears)) {
220
+    $arrayyears[$nowyear]=$nowyear;
221
+}
213 222
 
214 223
 $h=0;
215 224
 $head = array();
@@ -238,8 +247,12 @@  discard block
 block discarded – undo
238 247
 	print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
239 248
 	// Company
240 249
 	print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
241
-	if ($mode == 'customer') $filter='s.client in (1,2,3)';
242
-	if ($mode == 'supplier') $filter='s.fournisseur = 1';
250
+	if ($mode == 'customer') {
251
+	    $filter='s.client in (1,2,3)';
252
+	}
253
+	if ($mode == 'supplier') {
254
+	    $filter='s.fournisseur = 1';
255
+	}
243 256
 	print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
244 257
 	print '</td></tr>';
245 258
 	// User
@@ -248,8 +261,12 @@  discard block
 block discarded – undo
248 261
 	print '</td></tr>';
249 262
 	// Year
250 263
 	print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
251
-	if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
252
-	if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
264
+	if (! in_array($year,$arrayyears)) {
265
+	    $arrayyears[$year]=$year;
266
+	}
267
+	if (! in_array($nowyear,$arrayyears)) {
268
+	    $arrayyears[$nowyear]=$nowyear;
269
+	}
253 270
 	arsort($arrayyears);
254 271
 	print $form->selectarray('year',$arrayyears,$year,0);
255 272
 	print '</td></tr>';
@@ -289,8 +306,11 @@  discard block
 block discarded – undo
289 306
 
290 307
 	print '<tr class="oddeven" height="24">';
291 308
 	print '<td align="center">';
292
-	if ($year) print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a>';
293
-	else print $langs->trans("ValidationDateNotDefinedEvenIfShipmentValidated");
309
+	if ($year) {
310
+	    print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a>';
311
+	} else {
312
+	    print $langs->trans("ValidationDateNotDefinedEvenIfShipmentValidated");
313
+	}
294 314
 	print '</td>';
295 315
 	print '<td align="right">'.$val['nb'].'</td>';
296 316
 	/*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
@@ -308,8 +328,7 @@  discard block
 block discarded – undo
308 328
 
309 329
 // Show graphs
310 330
 print '<table class="border" width="100%"><tr class="pair nohover"><td align="center">';
311
-if ($mesg) { print $mesg; }
312
-else {
331
+if ($mesg) { print $mesg; } else {
313 332
     print $px1->show();
314 333
     print "<br>\n";
315 334
     /*print $px2->show();
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
27 27
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
28
-require DOL_BASE_PATH . '/main.inc.php';
29
-require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
28
+require DOL_BASE_PATH.'/main.inc.php';
29
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
32 32
 
33
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
34
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
33
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
34
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
35 35
 
36
-$userid=GETPOST('userid','int');
37
-$socid=GETPOST('socid','int');
36
+$userid = GETPOST('userid', 'int');
37
+$socid = GETPOST('socid', 'int');
38 38
 // Security check
39 39
 if ($user->societe_id > 0)
40 40
 {
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     $socid = $user->societe_id;
43 43
 }
44 44
 
45
-$nowyear=strftime("%Y", dol_now());
46
-$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
45
+$nowyear = strftime("%Y", dol_now());
46
+$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
47 47
 //$startyear=$year-2;
48
-$startyear=$year-1;
49
-$endyear=$year;
48
+$startyear = $year - 1;
49
+$endyear = $year;
50 50
 
51 51
 // Load translation files required by the page
52 52
 $langs->loadLangs(array('sendings', 'other', 'companies'));
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
  * View
57 57
  */
58 58
 
59
-$form=new Form($db);
59
+$form = new Form($db);
60 60
 
61 61
 llxHeader();
62 62
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 
66 66
 dol_mkdir($dir);
67 67
 
68
-$stats = new ExpeditionStats($db, $socid, $mode, ($userid>0?$userid:0));
68
+$stats = new ExpeditionStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
69 69
 
70 70
 // Build graphic number of object
71
-$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
71
+$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
72 72
 //var_dump($data);exit;
73 73
 // $data = array(array('Lib',val1,val2,val3),...)
74 74
 
@@ -88,29 +88,29 @@  discard block
 block discarded – undo
88 88
 
89 89
 $px1 = new DolGraph();
90 90
 $mesg = $px1->isGraphKo();
91
-if (! $mesg)
91
+if (!$mesg)
92 92
 {
93 93
     $px1->SetData($data);
94 94
     $px1->SetPrecisionY(0);
95
-    $i=$startyear;$legend=array();
95
+    $i = $startyear; $legend = array();
96 96
     while ($i <= $endyear)
97 97
     {
98
-        $legend[]=$i;
98
+        $legend[] = $i;
99 99
         $i++;
100 100
     }
101 101
     $px1->SetLegend($legend);
102 102
     $px1->SetMaxValue($px1->GetCeilMaxValue());
103
-    $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
103
+    $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
104 104
     $px1->SetWidth($WIDTH);
105 105
     $px1->SetHeight($HEIGHT);
106 106
     $px1->SetYLabel($langs->trans("NbOfSendings"));
107 107
     $px1->SetShading(3);
108 108
     $px1->SetHorizTickIncrement(1);
109 109
     $px1->SetPrecisionY(0);
110
-    $px1->mode='depth';
110
+    $px1->mode = 'depth';
111 111
     $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth"));
112 112
 
113
-    $px1->draw($filenamenb,$fileurlnb);
113
+    $px1->draw($filenamenb, $fileurlnb);
114 114
 }
115 115
 
116 116
 // Build graphic amount of object
@@ -205,24 +205,24 @@  discard block
 block discarded – undo
205 205
 
206 206
 // Show array
207 207
 $data = $stats->getAllByYear();
208
-$arrayyears=array();
209
-foreach($data as $val) {
210
-	if (! empty($val['year'])) {
211
-		$arrayyears[$val['year']]=$val['year'];
208
+$arrayyears = array();
209
+foreach ($data as $val) {
210
+	if (!empty($val['year'])) {
211
+		$arrayyears[$val['year']] = $val['year'];
212 212
 	}
213 213
 }
214
-if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
214
+if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
215 215
 
216
-$h=0;
216
+$h = 0;
217 217
 $head = array();
218
-$head[$h][0] = DOL_URL_ROOT . '/expedition/stats/index.php?mode='.$mode;
218
+$head[$h][0] = DOL_URL_ROOT.'/expedition/stats/index.php?mode='.$mode;
219 219
 $head[$h][1] = $langs->trans("ByMonthYear");
220 220
 $head[$h][2] = 'byyear';
221 221
 $h++;
222 222
 
223
-$type='shipment_stats';
223
+$type = 'shipment_stats';
224 224
 
225
-complete_head_from_modules($conf,$langs,null,$head,$h,$type);
225
+complete_head_from_modules($conf, $langs, null, $head, $h, $type);
226 226
 
227 227
 dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
228 228
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
241 241
 	// Company
242 242
 	print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
243
-	if ($mode == 'customer') $filter='s.client in (1,2,3)';
244
-	if ($mode == 'supplier') $filter='s.fournisseur = 1';
245
-	print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
243
+	if ($mode == 'customer') $filter = 's.client in (1,2,3)';
244
+	if ($mode == 'supplier') $filter = 's.fournisseur = 1';
245
+	print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"');
246 246
 	print '</td></tr>';
247 247
 	// User
248 248
 	print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	print '</td></tr>';
251 251
 	// Year
252 252
 	print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
253
-	if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
254
-	if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
253
+	if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
254
+	if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
255 255
 	arsort($arrayyears);
256
-	print $form->selectarray('year',$arrayyears,$year,0);
256
+	print $form->selectarray('year', $arrayyears, $year, 0);
257 257
 	print '</td></tr>';
258 258
 	print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
259 259
 	print '</table>';
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 print '<td align="center">'.$langs->trans("AmountAverage").'</td>';*/
272 272
 print '</tr>';
273 273
 
274
-$oldyear=0;
274
+$oldyear = 0;
275 275
 foreach ($data as $val)
276 276
 {
277 277
 	$year = $val['year'];
278
-	while (! empty($year) && $oldyear > $year+1)
278
+	while (!empty($year) && $oldyear > $year + 1)
279 279
 	{ // If we have empty year
280 280
 		$oldyear--;
281 281
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	/*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
299 299
 	print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';*/
300 300
 	print '</tr>';
301
-	$oldyear=$year;
301
+	$oldyear = $year;
302 302
 }
303 303
 
304 304
 print '</table>';
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/companypaymentmode.class.php 3 patches
Indentation   +495 added lines, -495 removed lines patch added patch discarded remove patch
@@ -32,279 +32,279 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class CompanyPaymentMode extends CommonObject
34 34
 {
35
-	/**
36
-	 * @var string ID to identify managed object
37
-	 */
38
-	public $element = 'companypaymentmode';
39
-
40
-	/**
41
-	 * @var string Name of table without prefix where object is stored
42
-	 */
43
-	public $table_element = 'societe_rib';
44
-
45
-	/**
46
-	 * @var int  Does companypaymentmode support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
47
-	 */
48
-	public $ismultientitymanaged = 2;
49
-
50
-	/**
51
-	 * @var int  Does companypaymentmode support extrafields ? 0=No, 1=Yes
52
-	 */
53
-	public $isextrafieldmanaged = 0;
54
-
55
-	/**
56
-	 * @var string String with name of icon for companypaymentmode. Must be the part after the 'object_' into object_companypaymentmode.png
57
-	 */
58
-	public $picto = 'generic';
59
-
60
-
61
-	/**
62
-	 *  'type' if the field format.
63
-	 *  'label' the translation key.
64
-	 *  'enabled' is a condition when the field must be managed.
65
-	 *  'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
66
-	 *  'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
67
-	 *  'index' if we want an index in database.
68
-	 *  'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
69
-	 *  'position' is the sort order of field.
70
-	 *  'searchall' is 1 if we want to search in this field when making a search from the quick search button.
71
-	 *  'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
72
-	 *  'help' is a string visible as a tooltip on field
73
-	 *  'comment' is not used. You can store here any text of your choice. It is not used by application.
74
-	 *  'default' is a default value for creation (can still be replaced by the global setup of default values)
75
-	 *  'showoncombobox' if field must be shown into the label of combobox
76
-	 */
77
-
78
-	// BEGIN MODULEBUILDER PROPERTIES
79
-	/**
80
-	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
81
-	 */
82
-	public $fields=array(
83
-		'rowid' =>array('type'=>'integer', 'label'=>'Rowid', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
84
-		'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15),
85
-		'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-2, 'position'=>30),
86
-		'bank' =>array('type'=>'varchar(255)', 'label'=>'Bank', 'enabled'=>1, 'visible'=>-2, 'position'=>35),
87
-		'code_banque' =>array('type'=>'varchar(128)', 'label'=>'Code banque', 'enabled'=>1, 'visible'=>-2, 'position'=>40),
88
-		'code_guichet' =>array('type'=>'varchar(6)', 'label'=>'Code guichet', 'enabled'=>1, 'visible'=>-2, 'position'=>45),
89
-		'number' =>array('type'=>'varchar(255)', 'label'=>'Number', 'enabled'=>1, 'visible'=>-2, 'position'=>50),
90
-		'cle_rib' =>array('type'=>'varchar(5)', 'label'=>'Cle rib', 'enabled'=>1, 'visible'=>-2, 'position'=>55),
91
-		'bic' =>array('type'=>'varchar(20)', 'label'=>'Bic', 'enabled'=>1, 'visible'=>-2, 'position'=>60),
92
-		'iban_prefix' =>array('type'=>'varchar(34)', 'label'=>'Iban prefix', 'enabled'=>1, 'visible'=>-2, 'position'=>65),
93
-		'domiciliation' =>array('type'=>'varchar(255)', 'label'=>'Domiciliation', 'enabled'=>1, 'visible'=>-2, 'position'=>70),
94
-		'proprio' =>array('type'=>'varchar(60)', 'label'=>'Proprio', 'enabled'=>1, 'visible'=>-2, 'position'=>75),
95
-		'owner_address' =>array('type'=>'text', 'label'=>'Owner address', 'enabled'=>1, 'visible'=>-2, 'position'=>80),
96
-		'default_rib' =>array('type'=>'tinyint(4)', 'label'=>'Default rib', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>85),
97
-		'rum' =>array('type'=>'varchar(32)', 'label'=>'Rum', 'enabled'=>1, 'visible'=>-2, 'position'=>90),
98
-		'date_rum' =>array('type'=>'date', 'label'=>'Date rum', 'enabled'=>1, 'visible'=>-2, 'position'=>95),
99
-		'frstrecur' =>array('type'=>'varchar(16)', 'label'=>'Frstrecur', 'enabled'=>1, 'visible'=>-2, 'position'=>100),
100
-		'type' =>array('type'=>'varchar(32)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-2, 'position'=>110),
101
-		'last_four' =>array('type'=>'varchar(4)', 'label'=>'Last four', 'enabled'=>1, 'visible'=>-2, 'position'=>115),
102
-		'card_type' =>array('type'=>'varchar(255)', 'label'=>'Card type', 'enabled'=>1, 'visible'=>-2, 'position'=>120),
103
-		'cvn' =>array('type'=>'varchar(255)', 'label'=>'Cvn', 'enabled'=>1, 'visible'=>-2, 'position'=>125),
104
-		'exp_date_month' =>array('type'=>'integer', 'label'=>'Exp date month', 'enabled'=>1, 'visible'=>-2, 'position'=>130),
105
-		'exp_date_year' =>array('type'=>'integer', 'label'=>'Exp date year', 'enabled'=>1, 'visible'=>-2, 'position'=>135),
106
-		'country_code' =>array('type'=>'varchar(10)', 'label'=>'Country code', 'enabled'=>1, 'visible'=>-2, 'position'=>140),
107
-		'approved' =>array('type'=>'integer', 'label'=>'Approved', 'enabled'=>1, 'visible'=>-2, 'position'=>145),
108
-		'email' =>array('type'=>'varchar(255)', 'label'=>'Email', 'enabled'=>1, 'visible'=>-2, 'position'=>150),
109
-		'max_total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Max total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>155),
110
-		'preapproval_key' =>array('type'=>'varchar(255)', 'label'=>'Preapproval key', 'enabled'=>1, 'visible'=>-2, 'position'=>160),
111
-		'total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>165),
112
-		'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'Stripe card ref', 'enabled'=>1, 'visible'=>-2, 'position'=>170),
113
-		'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>175),
114
-		'starting_date' =>array('type'=>'date', 'label'=>'Starting date', 'enabled'=>1, 'visible'=>-2, 'position'=>180),
115
-		'ending_date' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>1, 'visible'=>-2, 'position'=>185),
116
-		'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>20),
117
-		'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25),
118
-		'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>-2, 'position'=>105),
119
-	//'aaa' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>0, 'visible'=>-2, 'position'=>185),
120
-	);
121
-
122
-	/**
123
-	 * @var int ID
124
-	 */
125
-	public $rowid;
126
-
127
-	/**
128
-	 * @var int Thirdparty ID
129
-	 */
35
+    /**
36
+     * @var string ID to identify managed object
37
+     */
38
+    public $element = 'companypaymentmode';
39
+
40
+    /**
41
+     * @var string Name of table without prefix where object is stored
42
+     */
43
+    public $table_element = 'societe_rib';
44
+
45
+    /**
46
+     * @var int  Does companypaymentmode support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
47
+     */
48
+    public $ismultientitymanaged = 2;
49
+
50
+    /**
51
+     * @var int  Does companypaymentmode support extrafields ? 0=No, 1=Yes
52
+     */
53
+    public $isextrafieldmanaged = 0;
54
+
55
+    /**
56
+     * @var string String with name of icon for companypaymentmode. Must be the part after the 'object_' into object_companypaymentmode.png
57
+     */
58
+    public $picto = 'generic';
59
+
60
+
61
+    /**
62
+     *  'type' if the field format.
63
+     *  'label' the translation key.
64
+     *  'enabled' is a condition when the field must be managed.
65
+     *  'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
66
+     *  'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
67
+     *  'index' if we want an index in database.
68
+     *  'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
69
+     *  'position' is the sort order of field.
70
+     *  'searchall' is 1 if we want to search in this field when making a search from the quick search button.
71
+     *  'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
72
+     *  'help' is a string visible as a tooltip on field
73
+     *  'comment' is not used. You can store here any text of your choice. It is not used by application.
74
+     *  'default' is a default value for creation (can still be replaced by the global setup of default values)
75
+     *  'showoncombobox' if field must be shown into the label of combobox
76
+     */
77
+
78
+    // BEGIN MODULEBUILDER PROPERTIES
79
+    /**
80
+     * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
81
+     */
82
+    public $fields=array(
83
+        'rowid' =>array('type'=>'integer', 'label'=>'Rowid', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
84
+        'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15),
85
+        'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-2, 'position'=>30),
86
+        'bank' =>array('type'=>'varchar(255)', 'label'=>'Bank', 'enabled'=>1, 'visible'=>-2, 'position'=>35),
87
+        'code_banque' =>array('type'=>'varchar(128)', 'label'=>'Code banque', 'enabled'=>1, 'visible'=>-2, 'position'=>40),
88
+        'code_guichet' =>array('type'=>'varchar(6)', 'label'=>'Code guichet', 'enabled'=>1, 'visible'=>-2, 'position'=>45),
89
+        'number' =>array('type'=>'varchar(255)', 'label'=>'Number', 'enabled'=>1, 'visible'=>-2, 'position'=>50),
90
+        'cle_rib' =>array('type'=>'varchar(5)', 'label'=>'Cle rib', 'enabled'=>1, 'visible'=>-2, 'position'=>55),
91
+        'bic' =>array('type'=>'varchar(20)', 'label'=>'Bic', 'enabled'=>1, 'visible'=>-2, 'position'=>60),
92
+        'iban_prefix' =>array('type'=>'varchar(34)', 'label'=>'Iban prefix', 'enabled'=>1, 'visible'=>-2, 'position'=>65),
93
+        'domiciliation' =>array('type'=>'varchar(255)', 'label'=>'Domiciliation', 'enabled'=>1, 'visible'=>-2, 'position'=>70),
94
+        'proprio' =>array('type'=>'varchar(60)', 'label'=>'Proprio', 'enabled'=>1, 'visible'=>-2, 'position'=>75),
95
+        'owner_address' =>array('type'=>'text', 'label'=>'Owner address', 'enabled'=>1, 'visible'=>-2, 'position'=>80),
96
+        'default_rib' =>array('type'=>'tinyint(4)', 'label'=>'Default rib', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>85),
97
+        'rum' =>array('type'=>'varchar(32)', 'label'=>'Rum', 'enabled'=>1, 'visible'=>-2, 'position'=>90),
98
+        'date_rum' =>array('type'=>'date', 'label'=>'Date rum', 'enabled'=>1, 'visible'=>-2, 'position'=>95),
99
+        'frstrecur' =>array('type'=>'varchar(16)', 'label'=>'Frstrecur', 'enabled'=>1, 'visible'=>-2, 'position'=>100),
100
+        'type' =>array('type'=>'varchar(32)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-2, 'position'=>110),
101
+        'last_four' =>array('type'=>'varchar(4)', 'label'=>'Last four', 'enabled'=>1, 'visible'=>-2, 'position'=>115),
102
+        'card_type' =>array('type'=>'varchar(255)', 'label'=>'Card type', 'enabled'=>1, 'visible'=>-2, 'position'=>120),
103
+        'cvn' =>array('type'=>'varchar(255)', 'label'=>'Cvn', 'enabled'=>1, 'visible'=>-2, 'position'=>125),
104
+        'exp_date_month' =>array('type'=>'integer', 'label'=>'Exp date month', 'enabled'=>1, 'visible'=>-2, 'position'=>130),
105
+        'exp_date_year' =>array('type'=>'integer', 'label'=>'Exp date year', 'enabled'=>1, 'visible'=>-2, 'position'=>135),
106
+        'country_code' =>array('type'=>'varchar(10)', 'label'=>'Country code', 'enabled'=>1, 'visible'=>-2, 'position'=>140),
107
+        'approved' =>array('type'=>'integer', 'label'=>'Approved', 'enabled'=>1, 'visible'=>-2, 'position'=>145),
108
+        'email' =>array('type'=>'varchar(255)', 'label'=>'Email', 'enabled'=>1, 'visible'=>-2, 'position'=>150),
109
+        'max_total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Max total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>155),
110
+        'preapproval_key' =>array('type'=>'varchar(255)', 'label'=>'Preapproval key', 'enabled'=>1, 'visible'=>-2, 'position'=>160),
111
+        'total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>165),
112
+        'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'Stripe card ref', 'enabled'=>1, 'visible'=>-2, 'position'=>170),
113
+        'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>175),
114
+        'starting_date' =>array('type'=>'date', 'label'=>'Starting date', 'enabled'=>1, 'visible'=>-2, 'position'=>180),
115
+        'ending_date' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>1, 'visible'=>-2, 'position'=>185),
116
+        'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>20),
117
+        'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25),
118
+        'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>-2, 'position'=>105),
119
+    //'aaa' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>0, 'visible'=>-2, 'position'=>185),
120
+    );
121
+
122
+    /**
123
+     * @var int ID
124
+     */
125
+    public $rowid;
126
+
127
+    /**
128
+     * @var int Thirdparty ID
129
+     */
130 130
     public $fk_soc;
131 131
 
132
-	/**
132
+    /**
133 133
      * @var string company payment mode label
134 134
      */
135 135
     public $label;
136 136
 
137
-	public $bank;
138
-	public $code_banque;
139
-	public $code_guichet;
140
-	public $number;
141
-	public $cle_rib;
142
-	public $bic;
143
-	public $iban_prefix;
144
-	public $domiciliation;
145
-	public $proprio;
146
-	public $owner_address;
147
-	public $default_rib;
148
-	public $rum;
149
-	public $date_rum;
150
-	public $frstrecur;
151
-	public $type;
152
-	public $last_four;
153
-	public $card_type;
154
-	public $cvn;
155
-	public $exp_date_month;
156
-	public $exp_date_year;
157
-	public $country_code;
158
-	public $approved;
159
-	public $email;
160
-	public $max_total_amount_of_all_payments;
161
-	public $preapproval_key;
162
-	public $total_amount_of_all_payments;
163
-	public $stripe_card_ref;
164
-
165
-	/**
166
-	 * @var int Status
167
-	 */
168
-	public $status;
169
-
170
-	public $starting_date;
171
-	public $ending_date;
172
-	public $datec;
173
-	public $tms;
174
-	public $import_key;
175
-	// END MODULEBUILDER PROPERTIES
176
-
177
-
178
-
179
-	// If this object has a subtable with lines
180
-
181
-	/**
182
-	 * @var int    Name of subtable line
183
-	 */
184
-	//public $table_element_line = 'companypaymentmodedet';
185
-	/**
186
-	 * @var int    Field with ID of parent key if this field has a parent
187
-	 */
188
-	//public $fk_element = 'fk_companypaymentmode';
189
-	/**
190
-	 * @var int    Name of subtable class that manage subtable lines
191
-	 */
192
-	//public $class_element_line = 'CompanyPaymentModeline';
193
-	/**
194
-	 * @var array  Array of child tables (child tables to delete before deleting a record)
195
-	 */
196
-	//protected $childtables=array('companypaymentmodedet');
197
-	/**
198
-	 * @var CompanyPaymentModeLine[]     Array of subtable lines
199
-	 */
200
-	//public $lines = array();
201
-
202
-
203
-
204
-	/**
205
-	 * Constructor
206
-	 *
207
-	 * @param DoliDb $db Database handler
208
-	 */
209
-	public function __construct(DoliDB $db)
210
-	{
211
-		global $conf;
212
-
213
-		$this->db = $db;
214
-
215
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
216
-		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
217
-	}
218
-
219
-	/**
220
-	 * Create object into database
221
-	 *
222
-	 * @param  User $user      User that creates
223
-	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
224
-	 * @return int             <0 if KO, Id of created object if OK
225
-	 */
226
-	public function create(User $user, $notrigger = false)
227
-	{
228
-		$idpayment =  $this->createCommon($user, $notrigger);
229
-
230
-		return $idpayment;
231
-	}
232
-
233
-	/**
234
-	 * Clone and object into another one
235
-	 *
236
-	 * @param  	User 	$user      	User that creates
237
-	 * @param  	int 	$fromid     Id of object to clone
238
-	 * @return 	mixed 				New object created, <0 if KO
239
-	 */
240
-	public function createFromClone(User $user, $fromid)
241
-	{
242
-		global $hookmanager, $langs;
243
-	    $error = 0;
244
-
245
-	    dol_syslog(__METHOD__, LOG_DEBUG);
246
-
247
-	    $object = new self($this->db);
248
-
249
-	    $this->db->begin();
250
-
251
-	    // Load source object
252
-	    $object->fetchCommon($fromid);
253
-	    // Reset some properties
254
-	    unset($object->id);
255
-	    unset($object->fk_user_creat);
256
-	    unset($object->import_key);
257
-
258
-	    // Clear fields
259
-	    $object->ref = "copy_of_".$object->ref;
260
-	    $object->title = $langs->trans("CopyOf")." ".$object->title;
261
-	    // ...
262
-
263
-	    // Create clone
264
-		$object->context['createfromclone'] = 'createfromclone';
265
-	    $result = $object->createCommon($user);
266
-	    if ($result < 0) {
267
-	        $error++;
268
-	        $this->error = $object->error;
269
-	        $this->errors = $object->errors;
270
-	    }
271
-
272
-	    // End
273
-	    if (!$error) {
274
-	        $this->db->commit();
275
-	        return $object;
276
-	    } else {
277
-	        $this->db->rollback();
278
-	        return -1;
279
-	    }
280
-	}
281
-
282
-	/**
283
-	 * Load object in memory from the database
284
-	 *
285
-	 * @param 	int    	$id   	Id object
286
-	 * @param 	string 	$ref  	Ref
287
-	 * @param	int		$socid	Id of company to get first default payment mode
288
-	 * @param	string	$type	Filter on type ('ban', 'card', ...)
289
-	 * @return 	int         	<0 if KO, 0 if not found, >0 if OK
290
-	 */
291
-	public function fetch($id, $ref = null, $socid = 0, $type = '')
292
-	{
293
-		$morewhere = '';
294
-		if ($socid) $morewhere.= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
-		if ($type)  $morewhere.= " AND type = '".$this->db->escape($type)."'";
296
-
297
-		$result = $this->fetchCommon($id, $ref, $morewhere);
298
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
299
-		return $result;
300
-	}
301
-
302
-	/**
303
-	 * Load object lines in memory from the database
304
-	 *
305
-	 * @return int         <0 if KO, 0 if not found, >0 if OK
306
-	 */
307
-	/*public function fetchLines()
137
+    public $bank;
138
+    public $code_banque;
139
+    public $code_guichet;
140
+    public $number;
141
+    public $cle_rib;
142
+    public $bic;
143
+    public $iban_prefix;
144
+    public $domiciliation;
145
+    public $proprio;
146
+    public $owner_address;
147
+    public $default_rib;
148
+    public $rum;
149
+    public $date_rum;
150
+    public $frstrecur;
151
+    public $type;
152
+    public $last_four;
153
+    public $card_type;
154
+    public $cvn;
155
+    public $exp_date_month;
156
+    public $exp_date_year;
157
+    public $country_code;
158
+    public $approved;
159
+    public $email;
160
+    public $max_total_amount_of_all_payments;
161
+    public $preapproval_key;
162
+    public $total_amount_of_all_payments;
163
+    public $stripe_card_ref;
164
+
165
+    /**
166
+     * @var int Status
167
+     */
168
+    public $status;
169
+
170
+    public $starting_date;
171
+    public $ending_date;
172
+    public $datec;
173
+    public $tms;
174
+    public $import_key;
175
+    // END MODULEBUILDER PROPERTIES
176
+
177
+
178
+
179
+    // If this object has a subtable with lines
180
+
181
+    /**
182
+     * @var int    Name of subtable line
183
+     */
184
+    //public $table_element_line = 'companypaymentmodedet';
185
+    /**
186
+     * @var int    Field with ID of parent key if this field has a parent
187
+     */
188
+    //public $fk_element = 'fk_companypaymentmode';
189
+    /**
190
+     * @var int    Name of subtable class that manage subtable lines
191
+     */
192
+    //public $class_element_line = 'CompanyPaymentModeline';
193
+    /**
194
+     * @var array  Array of child tables (child tables to delete before deleting a record)
195
+     */
196
+    //protected $childtables=array('companypaymentmodedet');
197
+    /**
198
+     * @var CompanyPaymentModeLine[]     Array of subtable lines
199
+     */
200
+    //public $lines = array();
201
+
202
+
203
+
204
+    /**
205
+     * Constructor
206
+     *
207
+     * @param DoliDb $db Database handler
208
+     */
209
+    public function __construct(DoliDB $db)
210
+    {
211
+        global $conf;
212
+
213
+        $this->db = $db;
214
+
215
+        if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
216
+        if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
217
+    }
218
+
219
+    /**
220
+     * Create object into database
221
+     *
222
+     * @param  User $user      User that creates
223
+     * @param  bool $notrigger false=launch triggers after, true=disable triggers
224
+     * @return int             <0 if KO, Id of created object if OK
225
+     */
226
+    public function create(User $user, $notrigger = false)
227
+    {
228
+        $idpayment =  $this->createCommon($user, $notrigger);
229
+
230
+        return $idpayment;
231
+    }
232
+
233
+    /**
234
+     * Clone and object into another one
235
+     *
236
+     * @param  	User 	$user      	User that creates
237
+     * @param  	int 	$fromid     Id of object to clone
238
+     * @return 	mixed 				New object created, <0 if KO
239
+     */
240
+    public function createFromClone(User $user, $fromid)
241
+    {
242
+        global $hookmanager, $langs;
243
+        $error = 0;
244
+
245
+        dol_syslog(__METHOD__, LOG_DEBUG);
246
+
247
+        $object = new self($this->db);
248
+
249
+        $this->db->begin();
250
+
251
+        // Load source object
252
+        $object->fetchCommon($fromid);
253
+        // Reset some properties
254
+        unset($object->id);
255
+        unset($object->fk_user_creat);
256
+        unset($object->import_key);
257
+
258
+        // Clear fields
259
+        $object->ref = "copy_of_".$object->ref;
260
+        $object->title = $langs->trans("CopyOf")." ".$object->title;
261
+        // ...
262
+
263
+        // Create clone
264
+        $object->context['createfromclone'] = 'createfromclone';
265
+        $result = $object->createCommon($user);
266
+        if ($result < 0) {
267
+            $error++;
268
+            $this->error = $object->error;
269
+            $this->errors = $object->errors;
270
+        }
271
+
272
+        // End
273
+        if (!$error) {
274
+            $this->db->commit();
275
+            return $object;
276
+        } else {
277
+            $this->db->rollback();
278
+            return -1;
279
+        }
280
+    }
281
+
282
+    /**
283
+     * Load object in memory from the database
284
+     *
285
+     * @param 	int    	$id   	Id object
286
+     * @param 	string 	$ref  	Ref
287
+     * @param	int		$socid	Id of company to get first default payment mode
288
+     * @param	string	$type	Filter on type ('ban', 'card', ...)
289
+     * @return 	int         	<0 if KO, 0 if not found, >0 if OK
290
+     */
291
+    public function fetch($id, $ref = null, $socid = 0, $type = '')
292
+    {
293
+        $morewhere = '';
294
+        if ($socid) $morewhere.= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
+        if ($type)  $morewhere.= " AND type = '".$this->db->escape($type)."'";
296
+
297
+        $result = $this->fetchCommon($id, $ref, $morewhere);
298
+        if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
299
+        return $result;
300
+    }
301
+
302
+    /**
303
+     * Load object lines in memory from the database
304
+     *
305
+     * @return int         <0 if KO, 0 if not found, >0 if OK
306
+     */
307
+    /*public function fetchLines()
308 308
 	{
309 309
 		$this->lines=array();
310 310
 
@@ -313,43 +313,43 @@  discard block
 block discarded – undo
313 313
 		return count($this->lines)?1:0;
314 314
 	}*/
315 315
 
316
-	/**
317
-	 * Update object into database
318
-	 *
319
-	 * @param  User $user      User that modifies
320
-	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
321
-	 * @return int             <0 if KO, >0 if OK
322
-	 */
323
-	public function update(User $user, $notrigger = false)
324
-	{
325
-		return $this->updateCommon($user, $notrigger);
326
-	}
327
-
328
-	/**
329
-	 * Delete object in database
330
-	 *
331
-	 * @param User $user       User that deletes
332
-	 * @param bool $notrigger  false=launch triggers after, true=disable triggers
333
-	 * @return int             <0 if KO, >0 if OK
334
-	 */
335
-	public function delete(User $user, $notrigger = false)
336
-	{
337
-		return $this->deleteCommon($user, $notrigger);
338
-	}
339
-
340
-	/**
341
-	 *  Return a link to the object card (with optionaly the picto)
342
-	 *
343
-	 *	@param	int		$withpicto					Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
344
-	 *	@param	string	$option						On what the link point to ('nolink', ...)
316
+    /**
317
+     * Update object into database
318
+     *
319
+     * @param  User $user      User that modifies
320
+     * @param  bool $notrigger false=launch triggers after, true=disable triggers
321
+     * @return int             <0 if KO, >0 if OK
322
+     */
323
+    public function update(User $user, $notrigger = false)
324
+    {
325
+        return $this->updateCommon($user, $notrigger);
326
+    }
327
+
328
+    /**
329
+     * Delete object in database
330
+     *
331
+     * @param User $user       User that deletes
332
+     * @param bool $notrigger  false=launch triggers after, true=disable triggers
333
+     * @return int             <0 if KO, >0 if OK
334
+     */
335
+    public function delete(User $user, $notrigger = false)
336
+    {
337
+        return $this->deleteCommon($user, $notrigger);
338
+    }
339
+
340
+    /**
341
+     *  Return a link to the object card (with optionaly the picto)
342
+     *
343
+     *	@param	int		$withpicto					Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
344
+     *	@param	string	$option						On what the link point to ('nolink', ...)
345 345
      *  @param	int  	$notooltip					1=Disable tooltip
346 346
      *  @param  string  $morecss            		Add more css on link
347 347
      *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
348
-	 *	@return	string								String with URL
349
-	 */
350
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
351
-	{
352
-		global $db, $conf, $langs;
348
+     *	@return	string								String with URL
349
+     */
350
+    function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
351
+    {
352
+        global $db, $conf, $langs;
353 353
         global $dolibarr_main_authentication, $dolibarr_main_demo;
354 354
         global $menumanager;
355 355
 
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 
367 367
         if ($option != 'nolink')
368 368
         {
369
-	        // Add param to save lastsearch_values or not
370
-	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
371
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
372
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
369
+            // Add param to save lastsearch_values or not
370
+            $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
371
+            if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
372
+            if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
373 373
         }
374 374
 
375 375
         $linkclose='';
@@ -385,197 +385,197 @@  discard block
 block discarded – undo
385 385
         }
386 386
         else $linkclose = ($morecss?' class="'.$morecss.'"':'');
387 387
 
388
-		$linkstart = '<a href="'.$url.'"';
389
-		$linkstart.=$linkclose.'>';
390
-		$linkend='</a>';
391
-
392
-		$result .= $linkstart;
393
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
394
-		if ($withpicto != 2) $result.= $this->ref;
395
-		$result .= $linkend;
396
-		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
397
-
398
-		return $result;
399
-	}
400
-
401
-	/**
402
-	 * Set a Payment mode as Default
403
-	 *
404
-	 * @param   int     $id    		Payment mode ID
405
-	 * @param	string	$alltypes	1=The default is for all payment types instead of per type
406
-	 * @return  int             	0 if KO, 1 if OK
407
-	 */
408
-	function setAsDefault($id=0, $alltypes=0)
409
-	{
410
-		$sql1 = "SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX."societe_rib";
411
-		$sql1.= " WHERE rowid = ".($id?$id:$this->id);
412
-
413
-		dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
414
-		$result1 = $this->db->query($sql1);
415
-		if ($result1)
416
-		{
417
-			if ($this->db->num_rows($result1) == 0)
418
-			{
419
-				return 0;
420
-			}
421
-			else
422
-			{
423
-				$obj = $this->db->fetch_object($result1);
424
-
425
-				$type = '';
426
-				if (empty($alltypes)) $type = $obj->type;
427
-
428
-				$this->db->begin();
429
-
430
-				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
431
-				$sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
-				if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'";
433
-				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
434
-				$result2 = $this->db->query($sql2);
435
-
436
-				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
437
-				$sql3.= " WHERE rowid = ".$obj->id;
438
-				if ($type) $sql3.= " AND type = '".$this->db->escape($type)."'";
439
-				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
440
-				$result3 = $this->db->query($sql3);
441
-
442
-				if (!$result2 || !$result3)
443
-				{
444
-					dol_print_error($this->db);
445
-					$this->db->rollback();
446
-					return -1;
447
-				}
448
-				else
449
-				{
450
-					$this->db->commit();
451
-					return 1;
452
-				}
453
-			}
454
-		}
455
-		else
456
-		{
457
-			dol_print_error($this->db);
458
-			return -1;
459
-		}
460
-	}
461
-
462
-	/**
463
-	 *  Retourne le libelle du status d'un user (actif, inactif)
464
-	 *
465
-	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
466
-	 *  @return	string 			       Label of status
467
-	 */
468
-	function getLibStatut($mode=0)
469
-	{
470
-		return $this->LibStatut($this->status,$mode);
471
-	}
388
+        $linkstart = '<a href="'.$url.'"';
389
+        $linkstart.=$linkclose.'>';
390
+        $linkend='</a>';
391
+
392
+        $result .= $linkstart;
393
+        if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
394
+        if ($withpicto != 2) $result.= $this->ref;
395
+        $result .= $linkend;
396
+        //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
397
+
398
+        return $result;
399
+    }
400
+
401
+    /**
402
+     * Set a Payment mode as Default
403
+     *
404
+     * @param   int     $id    		Payment mode ID
405
+     * @param	string	$alltypes	1=The default is for all payment types instead of per type
406
+     * @return  int             	0 if KO, 1 if OK
407
+     */
408
+    function setAsDefault($id=0, $alltypes=0)
409
+    {
410
+        $sql1 = "SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX."societe_rib";
411
+        $sql1.= " WHERE rowid = ".($id?$id:$this->id);
412
+
413
+        dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
414
+        $result1 = $this->db->query($sql1);
415
+        if ($result1)
416
+        {
417
+            if ($this->db->num_rows($result1) == 0)
418
+            {
419
+                return 0;
420
+            }
421
+            else
422
+            {
423
+                $obj = $this->db->fetch_object($result1);
424
+
425
+                $type = '';
426
+                if (empty($alltypes)) $type = $obj->type;
427
+
428
+                $this->db->begin();
429
+
430
+                $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
431
+                $sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
+                if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'";
433
+                dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
434
+                $result2 = $this->db->query($sql2);
435
+
436
+                $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
437
+                $sql3.= " WHERE rowid = ".$obj->id;
438
+                if ($type) $sql3.= " AND type = '".$this->db->escape($type)."'";
439
+                dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
440
+                $result3 = $this->db->query($sql3);
441
+
442
+                if (!$result2 || !$result3)
443
+                {
444
+                    dol_print_error($this->db);
445
+                    $this->db->rollback();
446
+                    return -1;
447
+                }
448
+                else
449
+                {
450
+                    $this->db->commit();
451
+                    return 1;
452
+                }
453
+            }
454
+        }
455
+        else
456
+        {
457
+            dol_print_error($this->db);
458
+            return -1;
459
+        }
460
+    }
461
+
462
+    /**
463
+     *  Retourne le libelle du status d'un user (actif, inactif)
464
+     *
465
+     *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
466
+     *  @return	string 			       Label of status
467
+     */
468
+    function getLibStatut($mode=0)
469
+    {
470
+        return $this->LibStatut($this->status,$mode);
471
+    }
472 472
 
473 473
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
474
-	/**
475
-	 *  Return the status
476
-	 *
477
-	 *  @param	int		$status        	Id status
478
-	 *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
479
-	 *  @return string 			       	Label of status
480
-	 */
481
-	static function LibStatut($status,$mode=0)
482
-	{
474
+    /**
475
+     *  Return the status
476
+     *
477
+     *  @param	int		$status        	Id status
478
+     *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
479
+     *  @return string 			       	Label of status
480
+     */
481
+    static function LibStatut($status,$mode=0)
482
+    {
483 483
         // phpcs:enable
484
-		global $langs;
485
-
486
-		if ($mode == 0 || $mode == 1)
487
-		{
488
-			if ($status == 1) return $langs->trans('Enabled');
489
-			if ($status == 0) return $langs->trans('Disabled');
490
-		}
491
-		elseif ($mode == 2)
492
-		{
493
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
494
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
495
-		}
496
-		elseif ($mode == 3)
497
-		{
498
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
499
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
500
-		}
501
-		elseif ($mode == 4)
502
-		{
503
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
504
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
505
-		}
506
-		elseif ($mode == 5)
507
-		{
508
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
509
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
510
-		}
511
-		elseif ($mode == 6)
512
-		{
513
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
514
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
515
-		}
516
-	}
517
-
518
-	/**
519
-	 *	Charge les informations d'ordre info dans l'objet commande
520
-	 *
521
-	 *	@param  int		$id       Id of order
522
-	 *	@return	void
523
-	 */
524
-	function info($id)
525
-	{
526
-		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
527
-		$sql.= ' fk_user_creat, fk_user_modif';
528
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
529
-		$sql.= ' WHERE t.rowid = '.$id;
530
-		$result=$this->db->query($sql);
531
-		if ($result)
532
-		{
533
-			if ($this->db->num_rows($result))
534
-			{
535
-				$obj = $this->db->fetch_object($result);
536
-				$this->id = $obj->rowid;
537
-				if ($obj->fk_user_author)
538
-				{
539
-					$cuser = new User($this->db);
540
-					$cuser->fetch($obj->fk_user_author);
541
-					$this->user_creation   = $cuser;
542
-				}
543
-
544
-				if ($obj->fk_user_valid)
545
-				{
546
-					$vuser = new User($this->db);
547
-					$vuser->fetch($obj->fk_user_valid);
548
-					$this->user_validation = $vuser;
549
-				}
550
-
551
-				if ($obj->fk_user_cloture)
552
-				{
553
-					$cluser = new User($this->db);
554
-					$cluser->fetch($obj->fk_user_cloture);
555
-					$this->user_cloture   = $cluser;
556
-				}
557
-
558
-				$this->date_creation     = $this->db->jdate($obj->datec);
559
-				$this->date_modification = $this->db->jdate($obj->datem);
560
-				$this->date_validation   = $this->db->jdate($obj->datev);
561
-			}
562
-
563
-			$this->db->free($result);
564
-		}
565
-		else
566
-		{
567
-			dol_print_error($this->db);
568
-		}
569
-	}
570
-
571
-	/**
572
-	 * Initialise object with example values
573
-	 * Id must be 0 if object instance is a specimen
574
-	 *
575
-	 * @return void
576
-	 */
577
-	public function initAsSpecimen()
578
-	{
579
-		$this->initAsSpecimenCommon();
580
-	}
484
+        global $langs;
485
+
486
+        if ($mode == 0 || $mode == 1)
487
+        {
488
+            if ($status == 1) return $langs->trans('Enabled');
489
+            if ($status == 0) return $langs->trans('Disabled');
490
+        }
491
+        elseif ($mode == 2)
492
+        {
493
+            if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
494
+            if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
495
+        }
496
+        elseif ($mode == 3)
497
+        {
498
+            if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
499
+            if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
500
+        }
501
+        elseif ($mode == 4)
502
+        {
503
+            if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
504
+            if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
505
+        }
506
+        elseif ($mode == 5)
507
+        {
508
+            if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
509
+            if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
510
+        }
511
+        elseif ($mode == 6)
512
+        {
513
+            if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
514
+            if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
515
+        }
516
+    }
517
+
518
+    /**
519
+     *	Charge les informations d'ordre info dans l'objet commande
520
+     *
521
+     *	@param  int		$id       Id of order
522
+     *	@return	void
523
+     */
524
+    function info($id)
525
+    {
526
+        $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
527
+        $sql.= ' fk_user_creat, fk_user_modif';
528
+        $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
529
+        $sql.= ' WHERE t.rowid = '.$id;
530
+        $result=$this->db->query($sql);
531
+        if ($result)
532
+        {
533
+            if ($this->db->num_rows($result))
534
+            {
535
+                $obj = $this->db->fetch_object($result);
536
+                $this->id = $obj->rowid;
537
+                if ($obj->fk_user_author)
538
+                {
539
+                    $cuser = new User($this->db);
540
+                    $cuser->fetch($obj->fk_user_author);
541
+                    $this->user_creation   = $cuser;
542
+                }
543
+
544
+                if ($obj->fk_user_valid)
545
+                {
546
+                    $vuser = new User($this->db);
547
+                    $vuser->fetch($obj->fk_user_valid);
548
+                    $this->user_validation = $vuser;
549
+                }
550
+
551
+                if ($obj->fk_user_cloture)
552
+                {
553
+                    $cluser = new User($this->db);
554
+                    $cluser->fetch($obj->fk_user_cloture);
555
+                    $this->user_cloture   = $cluser;
556
+                }
557
+
558
+                $this->date_creation     = $this->db->jdate($obj->datec);
559
+                $this->date_modification = $this->db->jdate($obj->datem);
560
+                $this->date_validation   = $this->db->jdate($obj->datev);
561
+            }
562
+
563
+            $this->db->free($result);
564
+        }
565
+        else
566
+        {
567
+            dol_print_error($this->db);
568
+        }
569
+    }
570
+
571
+    /**
572
+     * Initialise object with example values
573
+     * Id must be 0 if object instance is a specimen
574
+     *
575
+     * @return void
576
+     */
577
+    public function initAsSpecimen()
578
+    {
579
+        $this->initAsSpecimenCommon();
580
+    }
581 581
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Put here all includes required by your class file
26
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27 27
 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
28 28
 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
29 29
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	/**
80 80
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
81 81
 	 */
82
-	public $fields=array(
82
+	public $fields = array(
83 83
 		'rowid' =>array('type'=>'integer', 'label'=>'Rowid', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
84 84
 		'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15),
85 85
 		'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-2, 'position'=>30),
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$this->db = $db;
214 214
 
215
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
216
-		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
215
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
216
+		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
217 217
 	}
218 218
 
219 219
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function create(User $user, $notrigger = false)
227 227
 	{
228
-		$idpayment =  $this->createCommon($user, $notrigger);
228
+		$idpayment = $this->createCommon($user, $notrigger);
229 229
 
230 230
 		return $idpayment;
231 231
 	}
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 	public function fetch($id, $ref = null, $socid = 0, $type = '')
292 292
 	{
293 293
 		$morewhere = '';
294
-		if ($socid) $morewhere.= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
-		if ($type)  $morewhere.= " AND type = '".$this->db->escape($type)."'";
294
+		if ($socid) $morewhere .= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
+		if ($type)  $morewhere .= " AND type = '".$this->db->escape($type)."'";
296 296
 
297 297
 		$result = $this->fetchCommon($id, $ref, $morewhere);
298
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
298
+		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
299 299
 		return $result;
300 300
 	}
301 301
 
@@ -347,51 +347,51 @@  discard block
 block discarded – undo
347 347
      *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
348 348
 	 *	@return	string								String with URL
349 349
 	 */
350
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
350
+	function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
351 351
 	{
352 352
 		global $db, $conf, $langs;
353 353
         global $dolibarr_main_authentication, $dolibarr_main_demo;
354 354
         global $menumanager;
355 355
 
356
-        if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
356
+        if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
357 357
 
358 358
         $result = '';
359 359
         $companylink = '';
360 360
 
361
-        $label = '<u>' . $langs->trans("CompanyPaymentMode") . '</u>';
362
-        $label.= '<br>';
363
-        $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
361
+        $label = '<u>'.$langs->trans("CompanyPaymentMode").'</u>';
362
+        $label .= '<br>';
363
+        $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
364 364
 
365
-        $url = dol_buildpath('/monmodule/companypaymentmode_card.php',1).'?id='.$this->id;
365
+        $url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?id='.$this->id;
366 366
 
367 367
         if ($option != 'nolink')
368 368
         {
369 369
 	        // Add param to save lastsearch_values or not
370
-	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
371
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
372
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
370
+	        $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
371
+	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
372
+	        if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
373 373
         }
374 374
 
375
-        $linkclose='';
375
+        $linkclose = '';
376 376
         if (empty($notooltip))
377 377
         {
378
-            if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
378
+            if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
379 379
             {
380
-                $label=$langs->trans("ShowCompanyPaymentMode");
381
-                $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
380
+                $label = $langs->trans("ShowCompanyPaymentMode");
381
+                $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
382 382
             }
383
-            $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
384
-            $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
383
+            $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
384
+            $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
385 385
         }
386
-        else $linkclose = ($morecss?' class="'.$morecss.'"':'');
386
+        else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
387 387
 
388 388
 		$linkstart = '<a href="'.$url.'"';
389
-		$linkstart.=$linkclose.'>';
390
-		$linkend='</a>';
389
+		$linkstart .= $linkclose.'>';
390
+		$linkend = '</a>';
391 391
 
392 392
 		$result .= $linkstart;
393
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
394
-		if ($withpicto != 2) $result.= $this->ref;
393
+		if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
394
+		if ($withpicto != 2) $result .= $this->ref;
395 395
 		$result .= $linkend;
396 396
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
397 397
 
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 	 * @param	string	$alltypes	1=The default is for all payment types instead of per type
406 406
 	 * @return  int             	0 if KO, 1 if OK
407 407
 	 */
408
-	function setAsDefault($id=0, $alltypes=0)
408
+	function setAsDefault($id = 0, $alltypes = 0)
409 409
 	{
410 410
 		$sql1 = "SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX."societe_rib";
411
-		$sql1.= " WHERE rowid = ".($id?$id:$this->id);
411
+		$sql1 .= " WHERE rowid = ".($id ? $id : $this->id);
412 412
 
413 413
 		dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
414 414
 		$result1 = $this->db->query($sql1);
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
 				$this->db->begin();
429 429
 
430 430
 				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
431
-				$sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
-				if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'";
431
+				$sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
+				if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'";
433 433
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
434 434
 				$result2 = $this->db->query($sql2);
435 435
 
436 436
 				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
437
-				$sql3.= " WHERE rowid = ".$obj->id;
438
-				if ($type) $sql3.= " AND type = '".$this->db->escape($type)."'";
437
+				$sql3 .= " WHERE rowid = ".$obj->id;
438
+				if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'";
439 439
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
440 440
 				$result3 = $this->db->query($sql3);
441 441
 
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
466 466
 	 *  @return	string 			       Label of status
467 467
 	 */
468
-	function getLibStatut($mode=0)
468
+	function getLibStatut($mode = 0)
469 469
 	{
470
-		return $this->LibStatut($this->status,$mode);
470
+		return $this->LibStatut($this->status, $mode);
471 471
 	}
472 472
 
473 473
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
479 479
 	 *  @return string 			       	Label of status
480 480
 	 */
481
-	static function LibStatut($status,$mode=0)
481
+	static function LibStatut($status, $mode = 0)
482 482
 	{
483 483
         // phpcs:enable
484 484
 		global $langs;
@@ -490,28 +490,28 @@  discard block
 block discarded – undo
490 490
 		}
491 491
 		elseif ($mode == 2)
492 492
 		{
493
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
494
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
493
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
494
+			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
495 495
 		}
496 496
 		elseif ($mode == 3)
497 497
 		{
498
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
499
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
498
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
499
+			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
500 500
 		}
501 501
 		elseif ($mode == 4)
502 502
 		{
503
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
504
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
503
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
504
+			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
505 505
 		}
506 506
 		elseif ($mode == 5)
507 507
 		{
508
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
509
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
508
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
509
+			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
510 510
 		}
511 511
 		elseif ($mode == 6)
512 512
 		{
513
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
514
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
513
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
514
+			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
515 515
 		}
516 516
 	}
517 517
 
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
 	function info($id)
525 525
 	{
526 526
 		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
527
-		$sql.= ' fk_user_creat, fk_user_modif';
528
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
529
-		$sql.= ' WHERE t.rowid = '.$id;
530
-		$result=$this->db->query($sql);
527
+		$sql .= ' fk_user_creat, fk_user_modif';
528
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
529
+		$sql .= ' WHERE t.rowid = '.$id;
530
+		$result = $this->db->query($sql);
531 531
 		if ($result)
532 532
 		{
533 533
 			if ($this->db->num_rows($result))
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 				{
539 539
 					$cuser = new User($this->db);
540 540
 					$cuser->fetch($obj->fk_user_author);
541
-					$this->user_creation   = $cuser;
541
+					$this->user_creation = $cuser;
542 542
 				}
543 543
 
544 544
 				if ($obj->fk_user_valid)
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 				{
553 553
 					$cluser = new User($this->db);
554 554
 					$cluser->fetch($obj->fk_user_cloture);
555
-					$this->user_cloture   = $cluser;
555
+					$this->user_cloture = $cluser;
556 556
 				}
557 557
 
558 558
 				$this->date_creation     = $this->db->jdate($obj->datec);
Please login to merge, or discard this patch.
Braces   +87 added lines, -44 removed lines patch added patch discarded remove patch
@@ -212,8 +212,12 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$this->db = $db;
214 214
 
215
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
216
-		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
215
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
216
+		    $this->fields['rowid']['visible']=0;
217
+		}
218
+		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
219
+		    $this->fields['entity']['enabled']=0;
220
+		}
217 221
 	}
218 222
 
219 223
 	/**
@@ -291,11 +295,17 @@  discard block
 block discarded – undo
291 295
 	public function fetch($id, $ref = null, $socid = 0, $type = '')
292 296
 	{
293 297
 		$morewhere = '';
294
-		if ($socid) $morewhere.= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
-		if ($type)  $morewhere.= " AND type = '".$this->db->escape($type)."'";
298
+		if ($socid) {
299
+		    $morewhere.= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
300
+		}
301
+		if ($type) {
302
+		    $morewhere.= " AND type = '".$this->db->escape($type)."'";
303
+		}
296 304
 
297 305
 		$result = $this->fetchCommon($id, $ref, $morewhere);
298
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
306
+		if ($result > 0 && ! empty($this->table_element_line)) {
307
+		    $this->fetchLines();
308
+		}
299 309
 		return $result;
300 310
 	}
301 311
 
@@ -353,7 +363,10 @@  discard block
 block discarded – undo
353 363
         global $dolibarr_main_authentication, $dolibarr_main_demo;
354 364
         global $menumanager;
355 365
 
356
-        if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
366
+        if (! empty($conf->dol_no_mouse_hover)) {
367
+            $notooltip=1;
368
+        }
369
+        // Force disable tooltips
357 370
 
358 371
         $result = '';
359 372
         $companylink = '';
@@ -368,8 +381,12 @@  discard block
 block discarded – undo
368 381
         {
369 382
 	        // Add param to save lastsearch_values or not
370 383
 	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
371
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
372
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
384
+	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) {
385
+	            $add_save_lastsearch_values=1;
386
+	        }
387
+	        if ($add_save_lastsearch_values) {
388
+	            $url.='&save_lastsearch_values=1';
389
+	        }
373 390
         }
374 391
 
375 392
         $linkclose='';
@@ -382,16 +399,21 @@  discard block
 block discarded – undo
382 399
             }
383 400
             $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
384 401
             $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
402
+        } else {
403
+            $linkclose = ($morecss?' class="'.$morecss.'"':'');
385 404
         }
386
-        else $linkclose = ($morecss?' class="'.$morecss.'"':'');
387 405
 
388 406
 		$linkstart = '<a href="'.$url.'"';
389 407
 		$linkstart.=$linkclose.'>';
390 408
 		$linkend='</a>';
391 409
 
392 410
 		$result .= $linkstart;
393
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
394
-		if ($withpicto != 2) $result.= $this->ref;
411
+		if ($withpicto) {
412
+		    $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
413
+		}
414
+		if ($withpicto != 2) {
415
+		    $result.= $this->ref;
416
+		}
395 417
 		$result .= $linkend;
396 418
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
397 419
 
@@ -417,25 +439,30 @@  discard block
 block discarded – undo
417 439
 			if ($this->db->num_rows($result1) == 0)
418 440
 			{
419 441
 				return 0;
420
-			}
421
-			else
442
+			} else
422 443
 			{
423 444
 				$obj = $this->db->fetch_object($result1);
424 445
 
425 446
 				$type = '';
426
-				if (empty($alltypes)) $type = $obj->type;
447
+				if (empty($alltypes)) {
448
+				    $type = $obj->type;
449
+				}
427 450
 
428 451
 				$this->db->begin();
429 452
 
430 453
 				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
431 454
 				$sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
-				if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'";
455
+				if ($type) {
456
+				    $sql2.= " AND type = '".$this->db->escape($type)."'";
457
+				}
433 458
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
434 459
 				$result2 = $this->db->query($sql2);
435 460
 
436 461
 				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
437 462
 				$sql3.= " WHERE rowid = ".$obj->id;
438
-				if ($type) $sql3.= " AND type = '".$this->db->escape($type)."'";
463
+				if ($type) {
464
+				    $sql3.= " AND type = '".$this->db->escape($type)."'";
465
+				}
439 466
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
440 467
 				$result3 = $this->db->query($sql3);
441 468
 
@@ -444,15 +471,13 @@  discard block
 block discarded – undo
444 471
 					dol_print_error($this->db);
445 472
 					$this->db->rollback();
446 473
 					return -1;
447
-				}
448
-				else
474
+				} else
449 475
 				{
450 476
 					$this->db->commit();
451 477
 					return 1;
452 478
 				}
453 479
 			}
454
-		}
455
-		else
480
+		} else
456 481
 		{
457 482
 			dol_print_error($this->db);
458 483
 			return -1;
@@ -485,33 +510,52 @@  discard block
 block discarded – undo
485 510
 
486 511
 		if ($mode == 0 || $mode == 1)
487 512
 		{
488
-			if ($status == 1) return $langs->trans('Enabled');
489
-			if ($status == 0) return $langs->trans('Disabled');
490
-		}
491
-		elseif ($mode == 2)
513
+			if ($status == 1) {
514
+			    return $langs->trans('Enabled');
515
+			}
516
+			if ($status == 0) {
517
+			    return $langs->trans('Disabled');
518
+			}
519
+		} elseif ($mode == 2)
492 520
 		{
493
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
494
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
495
-		}
496
-		elseif ($mode == 3)
521
+			if ($status == 1) {
522
+			    return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
523
+			}
524
+			if ($status == 0) {
525
+			    return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
526
+			}
527
+		} elseif ($mode == 3)
497 528
 		{
498
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
499
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
500
-		}
501
-		elseif ($mode == 4)
529
+			if ($status == 1) {
530
+			    return img_picto($langs->trans('Enabled'),'statut4');
531
+			}
532
+			if ($status == 0) {
533
+			    return img_picto($langs->trans('Disabled'),'statut5');
534
+			}
535
+		} elseif ($mode == 4)
502 536
 		{
503
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
504
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
505
-		}
506
-		elseif ($mode == 5)
537
+			if ($status == 1) {
538
+			    return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
539
+			}
540
+			if ($status == 0) {
541
+			    return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
542
+			}
543
+		} elseif ($mode == 5)
507 544
 		{
508
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
509
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
510
-		}
511
-		elseif ($mode == 6)
545
+			if ($status == 1) {
546
+			    return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
547
+			}
548
+			if ($status == 0) {
549
+			    return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
550
+			}
551
+		} elseif ($mode == 6)
512 552
 		{
513
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
514
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
553
+			if ($status == 1) {
554
+			    return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
555
+			}
556
+			if ($status == 0) {
557
+			    return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
558
+			}
515 559
 		}
516 560
 	}
517 561
 
@@ -561,8 +605,7 @@  discard block
 block discarded – undo
561 605
 			}
562 606
 
563 607
 			$this->db->free($result);
564
-		}
565
-		else
608
+		} else
566 609
 		{
567 610
 			dol_print_error($this->db);
568 611
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/address.class.php 3 patches
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -31,476 +31,476 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class Address
33 33
 {
34
-	protected $db;
34
+    protected $db;
35 35
 
36
-	/**
37
-	 * @var int ID
38
-	 */
39
-	public $id;
36
+    /**
37
+     * @var int ID
38
+     */
39
+    public $id;
40 40
 
41
-	public $type;
41
+    public $type;
42 42
 
43
-	/**
43
+    /**
44 44
      * @var string Address label
45 45
      */
46 46
     public $label;
47 47
 
48
-	public $socid;
49
-	public $name;
50
-
51
-	/**
52
-	 * @var string Address
53
-	 */
54
-	public $address;
55
-
56
-	public $zip;
57
-	public $town;
58
-	public $country_id;
59
-	public $country_code;
60
-	public $phone;
61
-	public $fax;
62
-	public $note;
63
-
64
-	/**
65
-	 * Adresses liees a la societe
66
-	 * @var array
67
-	 */
68
-	public $lines;
69
-
70
-	/**
71
-	 * Constructor
72
-	 *
73
-	 * @param DoliDB $db Database handler
74
-	 * @deprecated
75
-	 */
76
-	function __construct($db)
77
-	{
78
-		$this->db = $db;
79
-	}
80
-
81
-	/**
82
-	 *  Create address into database
83
-	 *
84
-	 *  @param	int		$socid      Company socid
85
-	 *  @param  User	$user       Object user making creation
86
-	 *  @return int         		0 if OK, < 0 if KO
87
-	 */
88
-	function create($socid, $user='')
89
-	{
90
-		global $langs,$conf;
91
-
92
-		// Nettoyage parametres
93
-		$this->name  = trim($this->name);
94
-		$this->label = trim($this->label);
95
-
96
-		dol_syslog(get_class($this)."::create label=".$this->label);
97
-
98
-		$this->db->begin();
99
-
100
-		$result = $this->verify();
101
-
102
-		if ($result >= 0)
103
-		{
104
-			$now=dol_now();
105
-
106
-			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) ";
107
-			$sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', '".$this->db->idate($now)."', '".$user->id."')";
108
-
109
-			$result=$this->db->query($sql);
110
-			if ($result)
111
-			{
112
-				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_address");
113
-
114
-				$ret = $this->update($this->id, $socid, $user);
115
-
116
-				if ($ret >= 0)
117
-				{
118
-					dol_syslog(get_class($this)."::create success id=".$this->id);
119
-					$this->db->commit();
120
-					return 0;
121
-				}
122
-				else
123
-				{
124
-					dol_syslog(get_class($this)."::create echec update");
125
-					$this->db->rollback();
126
-					return -3;
127
-				}
128
-			}
129
-			else
130
-
131
-			{
132
-				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
133
-				{
134
-
135
-					$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
136
-				}
137
-
138
-				$this->db->rollback();
139
-				return -2;
140
-			}
141
-		}
142
-		else
143
-		{
144
-			$this->db->rollback();
145
-			dol_syslog(get_class($this)."::create echec verify sql=$sql");
146
-			return -1;
147
-		}
148
-	}
149
-
150
-
151
-	/**
152
-	 *  Verification lors de la modification de l'adresse
153
-	 *
154
-	 *  @return		int	    0 if OK, <0 if KO
155
-	 */
156
-	function verify()
157
-	{
158
-		$this->label = trim($this->label);
159
-		$this->name  = trim($this->name);
160
-		$result = 0;
161
-		if (!$this->name || !$this->label)
162
-		{
163
-			$this->error = "The name of company and the label can not be empty.\n";
164
-			$result = -2;
165
-		}
166
-		return $result;
167
-	}
168
-
169
-
170
-	/**
171
-	 *  Mise a jour des parametres de l'adresse
172
-	 *
173
-	 *  @param	int		$id             id address
174
-	 *  @param	int		$socid			id third party
175
-	 *  @param  User	$user           Utilisateur qui demande la mise a jour
176
-	 *  @return int             		<0 if KO, >=0 if OK
177
-	 */
178
-	function update($id, $socid, $user='')
179
-	{
180
-		global $langs;
181
-
182
-		// Clean parameters
183
-		$this->fk_soc		= $socid;
184
-		$this->label		= trim($this->label);
185
-		$this->name			= trim($this->name);
186
-		$this->address		= trim($this->address);
187
-		$this->zip			= trim($this->zip);
188
-		$this->town			= trim($this->town);
189
-		$this->country_id	= trim($this->country_id);
190
-		$this->phone		= trim($this->phone);
191
-		$this->phone		= preg_replace("/\s/","",$this->phone);
192
-		$this->phone		= preg_replace("/\./","",$this->phone);
193
-		$this->fax			= trim($this->fax);
194
-		$this->fax			= preg_replace("/\s/","",$this->fax);
195
-		$this->fax			= preg_replace("/\./","",$this->fax);
196
-		$this->note			= trim($this->note);
197
-
198
-		$result = $this->verify();		// Verifie que name et label obligatoire
199
-
200
-		if ($result >= 0)
201
-		{
202
-			dol_syslog(get_class($this)."::Update verify ok");
203
-
204
-			$this->db->begin();
205
-
206
-			$sql = "UPDATE ".MAIN_DB_PREFIX."societe_address";
207
-			$sql.= " SET label = '" . $this->db->escape($this->label) ."'"; // Champ obligatoire
208
-			$sql.= ", name = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
209
-			$sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
210
-			$sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
211
-			$sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
212
-			$sql.= ", fk_pays = '" . ($this->country_id?$this->db->escape($this->country_id):'0') ."'";
213
-			$sql.= ", note = ".($this->note?"'".$this->db->escape($this->note)."'":"null");
214
-			$sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
215
-			$sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
216
-			if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
217
-			$sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $this->db->escape($id) ."'";
218
-
219
-			dol_syslog(get_class($this)."::Update", LOG_DEBUG);
220
-			$resql=$this->db->query($sql);
221
-			if ($resql)
222
-			{
223
-				dol_syslog(get_class($this)."::Update success");
224
-				$this->db->commit();
225
-				return 1;
226
-			}
227
-			else
228
-			{
229
-				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
230
-				{
231
-
232
-					$this->error=$langs->trans("ErrorDuplicateField",$this->name);
233
-					$result=-1;
234
-				}
235
-				else
236
-				{
237
-					$this->error=$this->db->lasterror();
238
-					$result=-2;
239
-				}
240
-				$this->db->rollback();
241
-				return $result;
242
-			}
243
-		}
244
-	}
48
+    public $socid;
49
+    public $name;
50
+
51
+    /**
52
+     * @var string Address
53
+     */
54
+    public $address;
55
+
56
+    public $zip;
57
+    public $town;
58
+    public $country_id;
59
+    public $country_code;
60
+    public $phone;
61
+    public $fax;
62
+    public $note;
63
+
64
+    /**
65
+     * Adresses liees a la societe
66
+     * @var array
67
+     */
68
+    public $lines;
69
+
70
+    /**
71
+     * Constructor
72
+     *
73
+     * @param DoliDB $db Database handler
74
+     * @deprecated
75
+     */
76
+    function __construct($db)
77
+    {
78
+        $this->db = $db;
79
+    }
80
+
81
+    /**
82
+     *  Create address into database
83
+     *
84
+     *  @param	int		$socid      Company socid
85
+     *  @param  User	$user       Object user making creation
86
+     *  @return int         		0 if OK, < 0 if KO
87
+     */
88
+    function create($socid, $user='')
89
+    {
90
+        global $langs,$conf;
91
+
92
+        // Nettoyage parametres
93
+        $this->name  = trim($this->name);
94
+        $this->label = trim($this->label);
95
+
96
+        dol_syslog(get_class($this)."::create label=".$this->label);
97
+
98
+        $this->db->begin();
99
+
100
+        $result = $this->verify();
101
+
102
+        if ($result >= 0)
103
+        {
104
+            $now=dol_now();
105
+
106
+            $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) ";
107
+            $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', '".$this->db->idate($now)."', '".$user->id."')";
108
+
109
+            $result=$this->db->query($sql);
110
+            if ($result)
111
+            {
112
+                $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_address");
113
+
114
+                $ret = $this->update($this->id, $socid, $user);
115
+
116
+                if ($ret >= 0)
117
+                {
118
+                    dol_syslog(get_class($this)."::create success id=".$this->id);
119
+                    $this->db->commit();
120
+                    return 0;
121
+                }
122
+                else
123
+                {
124
+                    dol_syslog(get_class($this)."::create echec update");
125
+                    $this->db->rollback();
126
+                    return -3;
127
+                }
128
+            }
129
+            else
130
+
131
+            {
132
+                if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
133
+                {
134
+
135
+                    $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
136
+                }
137
+
138
+                $this->db->rollback();
139
+                return -2;
140
+            }
141
+        }
142
+        else
143
+        {
144
+            $this->db->rollback();
145
+            dol_syslog(get_class($this)."::create echec verify sql=$sql");
146
+            return -1;
147
+        }
148
+    }
149
+
150
+
151
+    /**
152
+     *  Verification lors de la modification de l'adresse
153
+     *
154
+     *  @return		int	    0 if OK, <0 if KO
155
+     */
156
+    function verify()
157
+    {
158
+        $this->label = trim($this->label);
159
+        $this->name  = trim($this->name);
160
+        $result = 0;
161
+        if (!$this->name || !$this->label)
162
+        {
163
+            $this->error = "The name of company and the label can not be empty.\n";
164
+            $result = -2;
165
+        }
166
+        return $result;
167
+    }
168
+
169
+
170
+    /**
171
+     *  Mise a jour des parametres de l'adresse
172
+     *
173
+     *  @param	int		$id             id address
174
+     *  @param	int		$socid			id third party
175
+     *  @param  User	$user           Utilisateur qui demande la mise a jour
176
+     *  @return int             		<0 if KO, >=0 if OK
177
+     */
178
+    function update($id, $socid, $user='')
179
+    {
180
+        global $langs;
181
+
182
+        // Clean parameters
183
+        $this->fk_soc		= $socid;
184
+        $this->label		= trim($this->label);
185
+        $this->name			= trim($this->name);
186
+        $this->address		= trim($this->address);
187
+        $this->zip			= trim($this->zip);
188
+        $this->town			= trim($this->town);
189
+        $this->country_id	= trim($this->country_id);
190
+        $this->phone		= trim($this->phone);
191
+        $this->phone		= preg_replace("/\s/","",$this->phone);
192
+        $this->phone		= preg_replace("/\./","",$this->phone);
193
+        $this->fax			= trim($this->fax);
194
+        $this->fax			= preg_replace("/\s/","",$this->fax);
195
+        $this->fax			= preg_replace("/\./","",$this->fax);
196
+        $this->note			= trim($this->note);
197
+
198
+        $result = $this->verify();		// Verifie que name et label obligatoire
199
+
200
+        if ($result >= 0)
201
+        {
202
+            dol_syslog(get_class($this)."::Update verify ok");
203
+
204
+            $this->db->begin();
205
+
206
+            $sql = "UPDATE ".MAIN_DB_PREFIX."societe_address";
207
+            $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; // Champ obligatoire
208
+            $sql.= ", name = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
209
+            $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
210
+            $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
211
+            $sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
212
+            $sql.= ", fk_pays = '" . ($this->country_id?$this->db->escape($this->country_id):'0') ."'";
213
+            $sql.= ", note = ".($this->note?"'".$this->db->escape($this->note)."'":"null");
214
+            $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
215
+            $sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
216
+            if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
217
+            $sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $this->db->escape($id) ."'";
218
+
219
+            dol_syslog(get_class($this)."::Update", LOG_DEBUG);
220
+            $resql=$this->db->query($sql);
221
+            if ($resql)
222
+            {
223
+                dol_syslog(get_class($this)."::Update success");
224
+                $this->db->commit();
225
+                return 1;
226
+            }
227
+            else
228
+            {
229
+                if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
230
+                {
231
+
232
+                    $this->error=$langs->trans("ErrorDuplicateField",$this->name);
233
+                    $result=-1;
234
+                }
235
+                else
236
+                {
237
+                    $this->error=$this->db->lasterror();
238
+                    $result=-2;
239
+                }
240
+                $this->db->rollback();
241
+                return $result;
242
+            }
243
+        }
244
+    }
245 245
 
246 246
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
247
-	/**
248
-	 *  Charge depuis la base toutes les adresses d'une societe
249
-	 *
250
-	 *  @param	int		$socid       Id de la societe a charger en memoire
251
-	 *  @param  User	$user        Objet de l'utilisateur
252
-	 *  @return int 			     >0 si ok, <0 si ko
253
-	 */
254
-	function fetch_lines($socid, $user=null)
255
-	{
247
+    /**
248
+     *  Charge depuis la base toutes les adresses d'une societe
249
+     *
250
+     *  @param	int		$socid       Id de la societe a charger en memoire
251
+     *  @param  User	$user        Objet de l'utilisateur
252
+     *  @return int 			     >0 si ok, <0 si ko
253
+     */
254
+    function fetch_lines($socid, $user=null)
255
+    {
256 256
         // phpcs:enable
257
-		global $langs, $conf;
257
+        global $langs, $conf;
258 258
 
259
-		$sql = 'SELECT rowid, nom as name, client, fournisseur';
260
-		$sql .= ' FROM '.MAIN_DB_PREFIX.'societe';
261
-		$sql .= ' WHERE rowid = '.$socid;
259
+        $sql = 'SELECT rowid, nom as name, client, fournisseur';
260
+        $sql .= ' FROM '.MAIN_DB_PREFIX.'societe';
261
+        $sql .= ' WHERE rowid = '.$socid;
262 262
 
263
-		$resqlsoc=$this->db->query($sql);
264
-		if ($resqlsoc)
265
-		{
266
-			if ($this->db->num_rows($resqlsoc))
267
-			{
268
-				$obj = $this->db->fetch_object($resqlsoc);
263
+        $resqlsoc=$this->db->query($sql);
264
+        if ($resqlsoc)
265
+        {
266
+            if ($this->db->num_rows($resqlsoc))
267
+            {
268
+                $obj = $this->db->fetch_object($resqlsoc);
269 269
 
270
-				$this->socname 		= $obj->name;
271
-				$this->socid		= $obj->rowid;
272
-				$this->id			= $obj->rowid;
273
-				$this->client		= $obj->client;
274
-				$this->fournisseur	= $obj->fournisseur;
275
-			}
270
+                $this->socname 		= $obj->name;
271
+                $this->socid		= $obj->rowid;
272
+                $this->id			= $obj->rowid;
273
+                $this->client		= $obj->client;
274
+                $this->fournisseur	= $obj->fournisseur;
275
+            }
276 276
 
277
-			$this->db->free($resqlsoc);
277
+            $this->db->free($resqlsoc);
278 278
 
279 279
             $this->lines = array();
280 280
 
281 281
             // Adresses liees a la societe
282
-			if ($this->socid)
283
-			{
284
-				$sql = 'SELECT a.rowid as id, a.label, a.name, a.address, a.datec as date_creation, a.tms as date_modification, a.fk_soc';
285
-				$sql .= ', a.zip, a.town, a.note, a.fk_pays as country_id, a.phone, a.fax';
286
-				$sql .= ', c.code as country_code, c.label as country';
287
-				$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a';
288
-				$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON a.fk_pays = c.rowid';
289
-				$sql .= ' WHERE a.fk_soc = '.$this->socid;
290
-
291
-				$resql=$this->db->query($sql);
292
-				if ($resql)
293
-				{
294
-					$num = $this->db->num_rows($resql);
295
-					$i = 0;
296
-					while ($i < $num)
297
-					{
298
-						$objp = $this->db->fetch_object($resql);
299
-
300
-						$line = new AddressLine($this->db);
301
-
302
-						$line->id				= $objp->id;
303
-						$line->date_creation	 = $this->db->jdate($objp->date_creation);
304
-						$line->date_modification = $this->db->jdate($objp->date_modification);
305
-						$line->label			= $objp->label;
306
-						$line->name				= $objp->name;
307
-						$line->address			= $objp->address;
308
-						$line->zip				= $objp->zip;
309
-						$line->town				= $objp->town;
310
-						$line->country_id		= $objp->country_id;
311
-						$line->country_code		= $objp->country_id?$objp->country_code:'';
312
-						$line->country			= $objp->country_id?($langs->trans('Country'.$objp->country_code)!='Country'.$objp->country_code?$langs->trans('Country'.$objp->country_code):$objp->country):'';
313
-						$line->phone			= $objp->phone;
314
-						$line->fax				= $objp->fax;
315
-						$line->note				= $objp->note;
316
-
317
-						$this->lines[$i]		= $line;
318
-						$i++;
319
-					}
320
-					$this->db->free($resql);
321
-					return $num;
322
-				}
323
-				else
324
-				{
325
-					dol_syslog(get_class($this).'::Fetch Erreur: aucune adresse', LOG_ERR);
326
-					return 0;
327
-				}
328
-			}
329
-			else
330
-			{
331
-				dol_syslog(get_class($this).'::Fetch Erreur: societe inconnue', LOG_ERR);
332
-				return -1;
333
-			}
334
-		}
335
-		else
336
-		{
337
-			$this->error=$this->db->error();
338
-		}
339
-	}
282
+            if ($this->socid)
283
+            {
284
+                $sql = 'SELECT a.rowid as id, a.label, a.name, a.address, a.datec as date_creation, a.tms as date_modification, a.fk_soc';
285
+                $sql .= ', a.zip, a.town, a.note, a.fk_pays as country_id, a.phone, a.fax';
286
+                $sql .= ', c.code as country_code, c.label as country';
287
+                $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a';
288
+                $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON a.fk_pays = c.rowid';
289
+                $sql .= ' WHERE a.fk_soc = '.$this->socid;
290
+
291
+                $resql=$this->db->query($sql);
292
+                if ($resql)
293
+                {
294
+                    $num = $this->db->num_rows($resql);
295
+                    $i = 0;
296
+                    while ($i < $num)
297
+                    {
298
+                        $objp = $this->db->fetch_object($resql);
299
+
300
+                        $line = new AddressLine($this->db);
301
+
302
+                        $line->id				= $objp->id;
303
+                        $line->date_creation	 = $this->db->jdate($objp->date_creation);
304
+                        $line->date_modification = $this->db->jdate($objp->date_modification);
305
+                        $line->label			= $objp->label;
306
+                        $line->name				= $objp->name;
307
+                        $line->address			= $objp->address;
308
+                        $line->zip				= $objp->zip;
309
+                        $line->town				= $objp->town;
310
+                        $line->country_id		= $objp->country_id;
311
+                        $line->country_code		= $objp->country_id?$objp->country_code:'';
312
+                        $line->country			= $objp->country_id?($langs->trans('Country'.$objp->country_code)!='Country'.$objp->country_code?$langs->trans('Country'.$objp->country_code):$objp->country):'';
313
+                        $line->phone			= $objp->phone;
314
+                        $line->fax				= $objp->fax;
315
+                        $line->note				= $objp->note;
316
+
317
+                        $this->lines[$i]		= $line;
318
+                        $i++;
319
+                    }
320
+                    $this->db->free($resql);
321
+                    return $num;
322
+                }
323
+                else
324
+                {
325
+                    dol_syslog(get_class($this).'::Fetch Erreur: aucune adresse', LOG_ERR);
326
+                    return 0;
327
+                }
328
+            }
329
+            else
330
+            {
331
+                dol_syslog(get_class($this).'::Fetch Erreur: societe inconnue', LOG_ERR);
332
+                return -1;
333
+            }
334
+        }
335
+        else
336
+        {
337
+            $this->error=$this->db->error();
338
+        }
339
+    }
340 340
 
341 341
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
342
-	/**
343
-	 *  Charge depuis la base l'objet adresse
344
-	 *
345
-	 *  @param	int		$id       	Id de l'adresse a charger en memoire
346
-	 *  @param  User	$user       Objet de l'utilisateur
347
-	 *  @return int 				>0 si ok, <0 si ko
348
-	 */
349
-	function fetch_address($id, $user=null)
350
-	{
342
+    /**
343
+     *  Charge depuis la base l'objet adresse
344
+     *
345
+     *  @param	int		$id       	Id de l'adresse a charger en memoire
346
+     *  @param  User	$user       Objet de l'utilisateur
347
+     *  @return int 				>0 si ok, <0 si ko
348
+     */
349
+    function fetch_address($id, $user=null)
350
+    {
351 351
         // phpcs:enable
352
-		global $langs;
353
-		global $conf;
354
-
355
-		$sql = 'SELECT a.rowid, a.fk_soc, a.label, a.name, a.address, a.datec as date_creation, a.tms as date_modification';
356
-		$sql .= ', a.zip, a.town, a.note, a.fk_pays as country_id, a.phone, a.fax';
357
-		$sql .= ', c.code as country_code, c.label as country';
358
-		$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a';
359
-		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON a.fk_pays = c.rowid';
360
-		$sql .= ' WHERE a.rowid = '.$id;
361
-		$resql=$this->db->query($sql);
362
-		if ($resql)
363
-		{
364
-			if ($this->db->num_rows($resql))
365
-			{
366
-				$obj = $this->db->fetch_object($resql);
367
-
368
-				$this->id				= $obj->rowid;
369
-				$this->socid			= $obj->fk_soc;
370
-
371
-				$this->date_modification		= $this->db->jdate($obj->date_modification);
372
-				$this->date_creation 	= $this->db->jdate($obj->date_creation);
373
-
374
-				$this->label 			= $obj->label;
375
-				$this->name 			= $obj->name;
376
-				$this->address 			= $obj->address;
377
-				$this->zip 				= $obj->zip;
378
-				$this->town 			= $obj->town;
379
-
380
-				$this->country_id 		= $obj->country_id;
381
-				$this->country_code 	= $obj->country_id?$obj->country_code:'';
382
-				$this->country			= $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
383
-
384
-				$this->phone			= $obj->phone;
385
-				$this->fax				= $obj->fax;
386
-				$this->note				= $obj->note;
387
-
388
-				$result = 1;
389
-			}
390
-			else
391
-			{
392
-				dol_syslog('Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql);
393
-				$this->error='Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql;
394
-				$result = -2;
395
-			}
396
-
397
-			$this->db->free($resql);
398
-		}
399
-		else
400
-		{
401
-			dol_syslog('Erreur Societe::Fetch echec', LOG_DEBUG);
402
-			dol_syslog('Erreur Societe::Fetch '.$this->db->error());
403
-			$this->error=$this->db->error();
404
-			$result = -3;
405
-		}
406
-
407
-		return $result;
408
-	}
409
-
410
-
411
-	/**
412
-	 * 	Suppression d'une adresse
413
-	 *
414
-	 *  @param	int		$id      id de la societe a supprimer
415
-	 *  @param	int		$socid	id third party
416
-	 *  @return	<0 KO >0 OK
417
-	 */
418
-	function delete($id,$socid)
419
-	{
420
-		dol_syslog("Address::Delete");
421
-
422
-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_address";
423
-		$sql.= " WHERE rowid = ".$id;
424
-		$sql.= " AND fk_soc = ".$socid;
425
-
426
-		$result = $this->db->query($sql);
427
-
428
-		if (!$result) {
429
-			return -1;
430
-		}
431
-
432
-		return 1;
433
-	}
434
-
435
-	/**
436
-	 *  Return name of address with link (and eventually picto)
437
-	 *	Use $this->id, $this->label, $this->socid
438
-	 *
439
-	 *	@param		int			$withpicto		Include picto with link
440
-	 *	@param		string		$option			Where the link point to
441
-	 *	@return		string						String with URL
442
-	 */
443
-	function getNomUrl($withpicto=0,$option='')
444
-	{
445
-		global $langs;
446
-
447
-		$result='';
352
+        global $langs;
353
+        global $conf;
354
+
355
+        $sql = 'SELECT a.rowid, a.fk_soc, a.label, a.name, a.address, a.datec as date_creation, a.tms as date_modification';
356
+        $sql .= ', a.zip, a.town, a.note, a.fk_pays as country_id, a.phone, a.fax';
357
+        $sql .= ', c.code as country_code, c.label as country';
358
+        $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a';
359
+        $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON a.fk_pays = c.rowid';
360
+        $sql .= ' WHERE a.rowid = '.$id;
361
+        $resql=$this->db->query($sql);
362
+        if ($resql)
363
+        {
364
+            if ($this->db->num_rows($resql))
365
+            {
366
+                $obj = $this->db->fetch_object($resql);
367
+
368
+                $this->id				= $obj->rowid;
369
+                $this->socid			= $obj->fk_soc;
370
+
371
+                $this->date_modification		= $this->db->jdate($obj->date_modification);
372
+                $this->date_creation 	= $this->db->jdate($obj->date_creation);
373
+
374
+                $this->label 			= $obj->label;
375
+                $this->name 			= $obj->name;
376
+                $this->address 			= $obj->address;
377
+                $this->zip 				= $obj->zip;
378
+                $this->town 			= $obj->town;
379
+
380
+                $this->country_id 		= $obj->country_id;
381
+                $this->country_code 	= $obj->country_id?$obj->country_code:'';
382
+                $this->country			= $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
383
+
384
+                $this->phone			= $obj->phone;
385
+                $this->fax				= $obj->fax;
386
+                $this->note				= $obj->note;
387
+
388
+                $result = 1;
389
+            }
390
+            else
391
+            {
392
+                dol_syslog('Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql);
393
+                $this->error='Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql;
394
+                $result = -2;
395
+            }
396
+
397
+            $this->db->free($resql);
398
+        }
399
+        else
400
+        {
401
+            dol_syslog('Erreur Societe::Fetch echec', LOG_DEBUG);
402
+            dol_syslog('Erreur Societe::Fetch '.$this->db->error());
403
+            $this->error=$this->db->error();
404
+            $result = -3;
405
+        }
406
+
407
+        return $result;
408
+    }
409
+
410
+
411
+    /**
412
+     * 	Suppression d'une adresse
413
+     *
414
+     *  @param	int		$id      id de la societe a supprimer
415
+     *  @param	int		$socid	id third party
416
+     *  @return	<0 KO >0 OK
417
+     */
418
+    function delete($id,$socid)
419
+    {
420
+        dol_syslog("Address::Delete");
421
+
422
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_address";
423
+        $sql.= " WHERE rowid = ".$id;
424
+        $sql.= " AND fk_soc = ".$socid;
425
+
426
+        $result = $this->db->query($sql);
427
+
428
+        if (!$result) {
429
+            return -1;
430
+        }
431
+
432
+        return 1;
433
+    }
434
+
435
+    /**
436
+     *  Return name of address with link (and eventually picto)
437
+     *	Use $this->id, $this->label, $this->socid
438
+     *
439
+     *	@param		int			$withpicto		Include picto with link
440
+     *	@param		string		$option			Where the link point to
441
+     *	@return		string						String with URL
442
+     */
443
+    function getNomUrl($withpicto=0,$option='')
444
+    {
445
+        global $langs;
446
+
447
+        $result='';
448 448
         $label = $langs->trans("ShowAddress").': '.$this->label;
449 449
 
450 450
         $link = '<a href="'.DOL_URL_ROOT.'/comm/address.php?id='.$this->id.'&socid='.$this->socid.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
451
-		$linkend='</a>';
451
+        $linkend='</a>';
452 452
 
453 453
         if ($withpicto) $result.=($link.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$linkend.' ');
454
-		$result.=$link.$this->label.$linkend;
455
-		return $result;
456
-	}
457
-
458
-
459
-	/**
460
-	 * 	Charge les informations d'ordre info dans l'objet societe
461
-	 *
462
-	 *  @param  int		$id     id de la societe a charger
463
-	 *  @return	void
464
-	 */
465
-	function info($id)
466
-	{
467
-		$sql = "SELECT s.rowid, s.nom as name, datec as date_creation, tms as date_modification,";
468
-		$sql.= " fk_user_creat, fk_user_modif";
469
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
470
-		$sql.= " WHERE s.rowid = ".$id;
471
-
472
-		$result=$this->db->query($sql);
473
-		if ($result)
474
-		{
475
-			if ($this->db->num_rows($result))
476
-			{
477
-				$obj = $this->db->fetch_object($result);
478
-
479
-				$this->id = $obj->rowid;
480
-
481
-				if ($obj->fk_user_creat) {
482
-					$cuser = new User($this->db);
483
-					$cuser->fetch($obj->fk_user_creat);
484
-					$this->user_creation     = $cuser;
485
-				}
486
-
487
-				if ($obj->fk_user_modif) {
488
-					$muser = new User($this->db);
489
-					$muser->fetch($obj->fk_user_modif);
490
-					$this->user_modification = $muser;
491
-				}
492
-				$this->ref			     = $obj->name;
493
-				$this->date_creation     = $this->db->jdate($obj->date_creation);
494
-				$this->date_modification = $this->db->jdate($obj->date_modification);
495
-			}
496
-
497
-			$this->db->free($result);
498
-		}
499
-		else
500
-		{
501
-			dol_print_error($this->db);
502
-		}
503
-	}
454
+        $result.=$link.$this->label.$linkend;
455
+        return $result;
456
+    }
457
+
458
+
459
+    /**
460
+     * 	Charge les informations d'ordre info dans l'objet societe
461
+     *
462
+     *  @param  int		$id     id de la societe a charger
463
+     *  @return	void
464
+     */
465
+    function info($id)
466
+    {
467
+        $sql = "SELECT s.rowid, s.nom as name, datec as date_creation, tms as date_modification,";
468
+        $sql.= " fk_user_creat, fk_user_modif";
469
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
470
+        $sql.= " WHERE s.rowid = ".$id;
471
+
472
+        $result=$this->db->query($sql);
473
+        if ($result)
474
+        {
475
+            if ($this->db->num_rows($result))
476
+            {
477
+                $obj = $this->db->fetch_object($result);
478
+
479
+                $this->id = $obj->rowid;
480
+
481
+                if ($obj->fk_user_creat) {
482
+                    $cuser = new User($this->db);
483
+                    $cuser->fetch($obj->fk_user_creat);
484
+                    $this->user_creation     = $cuser;
485
+                }
486
+
487
+                if ($obj->fk_user_modif) {
488
+                    $muser = new User($this->db);
489
+                    $muser->fetch($obj->fk_user_modif);
490
+                    $this->user_modification = $muser;
491
+                }
492
+                $this->ref			     = $obj->name;
493
+                $this->date_creation     = $this->db->jdate($obj->date_creation);
494
+                $this->date_modification = $this->db->jdate($obj->date_modification);
495
+            }
496
+
497
+            $this->db->free($result);
498
+        }
499
+        else
500
+        {
501
+            dol_print_error($this->db);
502
+        }
503
+    }
504 504
 }
505 505
 
506 506
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
  */
510 510
 class AddressLine
511 511
 {
512
-	protected $db;
512
+    protected $db;
513 513
 
514
-	/**
515
-	 * @var int ID
516
-	 */
517
-	public $id;
514
+    /**
515
+     * @var int ID
516
+     */
517
+    public $id;
518 518
 
519
-	public $date_creation;
520
-	public $date_modification;
519
+    public $date_creation;
520
+    public $date_modification;
521 521
 
522
-	/**
522
+    /**
523 523
      * @var string stock movements label
524 524
      */
525 525
     public $label;
526 526
 
527
-	public $name;
528
-
529
-	/**
530
-	 * @var string Address
531
-	 */
532
-	public $address;
533
-
534
-	public $zip;
535
-	public $town;
536
-	public $country_id;
537
-	public $country_code;
538
-	public $country;
539
-	public $phone;
540
-	public $fax;
541
-	public $note;
542
-
543
-
544
-	/**
545
-	 *  Constructor
546
-	 *
547
-	 *  @param	DoliDB		$db     Database handler
548
-	 */
549
-	function __construct($db)
550
-	{
551
-		$this->db = $db;
552
-	}
527
+    public $name;
528
+
529
+    /**
530
+     * @var string Address
531
+     */
532
+    public $address;
533
+
534
+    public $zip;
535
+    public $town;
536
+    public $country_id;
537
+    public $country_code;
538
+    public $country;
539
+    public $phone;
540
+    public $fax;
541
+    public $note;
542
+
543
+
544
+    /**
545
+     *  Constructor
546
+     *
547
+     *  @param	DoliDB		$db     Database handler
548
+     */
549
+    function __construct($db)
550
+    {
551
+        $this->db = $db;
552
+    }
553 553
 }
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 *  @param  User	$user       Object user making creation
86 86
 	 *  @return int         		0 if OK, < 0 if KO
87 87
 	 */
88
-	function create($socid, $user='')
88
+	function create($socid, $user = '')
89 89
 	{
90
-		global $langs,$conf;
90
+		global $langs, $conf;
91 91
 
92 92
 		// Nettoyage parametres
93 93
 		$this->name  = trim($this->name);
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 
102 102
 		if ($result >= 0)
103 103
 		{
104
-			$now=dol_now();
104
+			$now = dol_now();
105 105
 
106 106
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) ";
107 107
 			$sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', '".$this->db->idate($now)."', '".$user->id."')";
108 108
 
109
-			$result=$this->db->query($sql);
109
+			$result = $this->db->query($sql);
110 110
 			if ($result)
111 111
 			{
112 112
 				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_address");
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
133 133
 				{
134 134
 
135
-					$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
135
+					$this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name);
136 136
 				}
137 137
 
138 138
 				$this->db->rollback();
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 	 *  @param  User	$user           Utilisateur qui demande la mise a jour
176 176
 	 *  @return int             		<0 if KO, >=0 if OK
177 177
 	 */
178
-	function update($id, $socid, $user='')
178
+	function update($id, $socid, $user = '')
179 179
 	{
180 180
 		global $langs;
181 181
 
182 182
 		// Clean parameters
183
-		$this->fk_soc		= $socid;
183
+		$this->fk_soc = $socid;
184 184
 		$this->label		= trim($this->label);
185 185
 		$this->name			= trim($this->name);
186
-		$this->address		= trim($this->address);
187
-		$this->zip			= trim($this->zip);
186
+		$this->address = trim($this->address);
187
+		$this->zip = trim($this->zip);
188 188
 		$this->town			= trim($this->town);
189
-		$this->country_id	= trim($this->country_id);
189
+		$this->country_id = trim($this->country_id);
190 190
 		$this->phone		= trim($this->phone);
191
-		$this->phone		= preg_replace("/\s/","",$this->phone);
192
-		$this->phone		= preg_replace("/\./","",$this->phone);
191
+		$this->phone		= preg_replace("/\s/", "", $this->phone);
192
+		$this->phone		= preg_replace("/\./", "", $this->phone);
193 193
 		$this->fax			= trim($this->fax);
194
-		$this->fax			= preg_replace("/\s/","",$this->fax);
195
-		$this->fax			= preg_replace("/\./","",$this->fax);
196
-		$this->note			= trim($this->note);
194
+		$this->fax			= preg_replace("/\s/", "", $this->fax);
195
+		$this->fax			= preg_replace("/\./", "", $this->fax);
196
+		$this->note = trim($this->note);
197 197
 
198
-		$result = $this->verify();		// Verifie que name et label obligatoire
198
+		$result = $this->verify(); // Verifie que name et label obligatoire
199 199
 
200 200
 		if ($result >= 0)
201 201
 		{
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
 			$this->db->begin();
205 205
 
206 206
 			$sql = "UPDATE ".MAIN_DB_PREFIX."societe_address";
207
-			$sql.= " SET label = '" . $this->db->escape($this->label) ."'"; // Champ obligatoire
208
-			$sql.= ", name = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
209
-			$sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
210
-			$sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
211
-			$sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
212
-			$sql.= ", fk_pays = '" . ($this->country_id?$this->db->escape($this->country_id):'0') ."'";
213
-			$sql.= ", note = ".($this->note?"'".$this->db->escape($this->note)."'":"null");
214
-			$sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
215
-			$sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
207
+			$sql .= " SET label = '".$this->db->escape($this->label)."'"; // Champ obligatoire
208
+			$sql .= ", name = '".$this->db->escape($this->name)."'"; // Champ obligatoire
209
+			$sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null");
210
+			$sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null");
211
+			$sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null");
212
+			$sql .= ", fk_pays = '".($this->country_id ? $this->db->escape($this->country_id) : '0')."'";
213
+			$sql .= ", note = ".($this->note ? "'".$this->db->escape($this->note)."'" : "null");
214
+			$sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null");
215
+			$sql .= ", fax = ".($this->fax ? "'".$this->db->escape($this->fax)."'" : "null");
216 216
 			if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
217
-			$sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $this->db->escape($id) ."'";
217
+			$sql .= " WHERE fk_soc = '".$socid."' AND rowid = '".$this->db->escape($id)."'";
218 218
 
219 219
 			dol_syslog(get_class($this)."::Update", LOG_DEBUG);
220
-			$resql=$this->db->query($sql);
220
+			$resql = $this->db->query($sql);
221 221
 			if ($resql)
222 222
 			{
223 223
 				dol_syslog(get_class($this)."::Update success");
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
230 230
 				{
231 231
 
232
-					$this->error=$langs->trans("ErrorDuplicateField",$this->name);
233
-					$result=-1;
232
+					$this->error = $langs->trans("ErrorDuplicateField", $this->name);
233
+					$result = -1;
234 234
 				}
235 235
 				else
236 236
 				{
237
-					$this->error=$this->db->lasterror();
238
-					$result=-2;
237
+					$this->error = $this->db->lasterror();
238
+					$result = -2;
239 239
 				}
240 240
 				$this->db->rollback();
241 241
 				return $result;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 *  @param  User	$user        Objet de l'utilisateur
252 252
 	 *  @return int 			     >0 si ok, <0 si ko
253 253
 	 */
254
-	function fetch_lines($socid, $user=null)
254
+	function fetch_lines($socid, $user = null)
255 255
 	{
256 256
         // phpcs:enable
257 257
 		global $langs, $conf;
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'societe';
261 261
 		$sql .= ' WHERE rowid = '.$socid;
262 262
 
263
-		$resqlsoc=$this->db->query($sql);
263
+		$resqlsoc = $this->db->query($sql);
264 264
 		if ($resqlsoc)
265 265
 		{
266 266
 			if ($this->db->num_rows($resqlsoc))
267 267
 			{
268 268
 				$obj = $this->db->fetch_object($resqlsoc);
269 269
 
270
-				$this->socname 		= $obj->name;
271
-				$this->socid		= $obj->rowid;
272
-				$this->id			= $obj->rowid;
273
-				$this->client		= $obj->client;
274
-				$this->fournisseur	= $obj->fournisseur;
270
+				$this->socname = $obj->name;
271
+				$this->socid = $obj->rowid;
272
+				$this->id = $obj->rowid;
273
+				$this->client = $obj->client;
274
+				$this->fournisseur = $obj->fournisseur;
275 275
 			}
276 276
 
277 277
 			$this->db->free($resqlsoc);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 				$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON a.fk_pays = c.rowid';
289 289
 				$sql .= ' WHERE a.fk_soc = '.$this->socid;
290 290
 
291
-				$resql=$this->db->query($sql);
291
+				$resql = $this->db->query($sql);
292 292
 				if ($resql)
293 293
 				{
294 294
 					$num = $this->db->num_rows($resql);
@@ -299,22 +299,22 @@  discard block
 block discarded – undo
299 299
 
300 300
 						$line = new AddressLine($this->db);
301 301
 
302
-						$line->id				= $objp->id;
303
-						$line->date_creation	 = $this->db->jdate($objp->date_creation);
302
+						$line->id = $objp->id;
303
+						$line->date_creation = $this->db->jdate($objp->date_creation);
304 304
 						$line->date_modification = $this->db->jdate($objp->date_modification);
305 305
 						$line->label			= $objp->label;
306 306
 						$line->name				= $objp->name;
307
-						$line->address			= $objp->address;
308
-						$line->zip				= $objp->zip;
307
+						$line->address = $objp->address;
308
+						$line->zip = $objp->zip;
309 309
 						$line->town				= $objp->town;
310
-						$line->country_id		= $objp->country_id;
311
-						$line->country_code		= $objp->country_id?$objp->country_code:'';
312
-						$line->country			= $objp->country_id?($langs->trans('Country'.$objp->country_code)!='Country'.$objp->country_code?$langs->trans('Country'.$objp->country_code):$objp->country):'';
310
+						$line->country_id = $objp->country_id;
311
+						$line->country_code = $objp->country_id ? $objp->country_code : '';
312
+						$line->country = $objp->country_id ? ($langs->trans('Country'.$objp->country_code) != 'Country'.$objp->country_code ? $langs->trans('Country'.$objp->country_code) : $objp->country) : '';
313 313
 						$line->phone			= $objp->phone;
314
-						$line->fax				= $objp->fax;
314
+						$line->fax = $objp->fax;
315 315
 						$line->note				= $objp->note;
316 316
 
317
-						$this->lines[$i]		= $line;
317
+						$this->lines[$i] = $line;
318 318
 						$i++;
319 319
 					}
320 320
 					$this->db->free($resql);
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 		else
336 336
 		{
337
-			$this->error=$this->db->error();
337
+			$this->error = $this->db->error();
338 338
 		}
339 339
 	}
340 340
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 *  @param  User	$user       Objet de l'utilisateur
347 347
 	 *  @return int 				>0 si ok, <0 si ko
348 348
 	 */
349
-	function fetch_address($id, $user=null)
349
+	function fetch_address($id, $user = null)
350 350
 	{
351 351
         // phpcs:enable
352 352
 		global $langs;
@@ -358,31 +358,31 @@  discard block
 block discarded – undo
358 358
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a';
359 359
 		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON a.fk_pays = c.rowid';
360 360
 		$sql .= ' WHERE a.rowid = '.$id;
361
-		$resql=$this->db->query($sql);
361
+		$resql = $this->db->query($sql);
362 362
 		if ($resql)
363 363
 		{
364 364
 			if ($this->db->num_rows($resql))
365 365
 			{
366 366
 				$obj = $this->db->fetch_object($resql);
367 367
 
368
-				$this->id				= $obj->rowid;
369
-				$this->socid			= $obj->fk_soc;
368
+				$this->id = $obj->rowid;
369
+				$this->socid = $obj->fk_soc;
370 370
 
371
-				$this->date_modification		= $this->db->jdate($obj->date_modification);
372
-				$this->date_creation 	= $this->db->jdate($obj->date_creation);
371
+				$this->date_modification = $this->db->jdate($obj->date_modification);
372
+				$this->date_creation = $this->db->jdate($obj->date_creation);
373 373
 
374
-				$this->label 			= $obj->label;
374
+				$this->label = $obj->label;
375 375
 				$this->name 			= $obj->name;
376
-				$this->address 			= $obj->address;
376
+				$this->address = $obj->address;
377 377
 				$this->zip 				= $obj->zip;
378 378
 				$this->town 			= $obj->town;
379 379
 
380
-				$this->country_id 		= $obj->country_id;
381
-				$this->country_code 	= $obj->country_id?$obj->country_code:'';
382
-				$this->country			= $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
380
+				$this->country_id = $obj->country_id;
381
+				$this->country_code = $obj->country_id ? $obj->country_code : '';
382
+				$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->trans('Country'.$obj->country_code) : $obj->country) : '';
383 383
 
384 384
 				$this->phone			= $obj->phone;
385
-				$this->fax				= $obj->fax;
385
+				$this->fax = $obj->fax;
386 386
 				$this->note				= $obj->note;
387 387
 
388 388
 				$result = 1;
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 			else
391 391
 			{
392 392
 				dol_syslog('Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql);
393
-				$this->error='Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql;
393
+				$this->error = 'Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql;
394 394
 				$result = -2;
395 395
 			}
396 396
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		{
401 401
 			dol_syslog('Erreur Societe::Fetch echec', LOG_DEBUG);
402 402
 			dol_syslog('Erreur Societe::Fetch '.$this->db->error());
403
-			$this->error=$this->db->error();
403
+			$this->error = $this->db->error();
404 404
 			$result = -3;
405 405
 		}
406 406
 
@@ -415,13 +415,13 @@  discard block
 block discarded – undo
415 415
 	 *  @param	int		$socid	id third party
416 416
 	 *  @return	<0 KO >0 OK
417 417
 	 */
418
-	function delete($id,$socid)
418
+	function delete($id, $socid)
419 419
 	{
420 420
 		dol_syslog("Address::Delete");
421 421
 
422 422
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_address";
423
-		$sql.= " WHERE rowid = ".$id;
424
-		$sql.= " AND fk_soc = ".$socid;
423
+		$sql .= " WHERE rowid = ".$id;
424
+		$sql .= " AND fk_soc = ".$socid;
425 425
 
426 426
 		$result = $this->db->query($sql);
427 427
 
@@ -440,18 +440,18 @@  discard block
 block discarded – undo
440 440
 	 *	@param		string		$option			Where the link point to
441 441
 	 *	@return		string						String with URL
442 442
 	 */
443
-	function getNomUrl($withpicto=0,$option='')
443
+	function getNomUrl($withpicto = 0, $option = '')
444 444
 	{
445 445
 		global $langs;
446 446
 
447
-		$result='';
447
+		$result = '';
448 448
         $label = $langs->trans("ShowAddress").': '.$this->label;
449 449
 
450 450
         $link = '<a href="'.DOL_URL_ROOT.'/comm/address.php?id='.$this->id.'&socid='.$this->socid.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
451
-		$linkend='</a>';
451
+		$linkend = '</a>';
452 452
 
453
-        if ($withpicto) $result.=($link.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$linkend.' ');
454
-		$result.=$link.$this->label.$linkend;
453
+        if ($withpicto) $result .= ($link.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$linkend.' ');
454
+		$result .= $link.$this->label.$linkend;
455 455
 		return $result;
456 456
 	}
457 457
 
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 	function info($id)
466 466
 	{
467 467
 		$sql = "SELECT s.rowid, s.nom as name, datec as date_creation, tms as date_modification,";
468
-		$sql.= " fk_user_creat, fk_user_modif";
469
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
470
-		$sql.= " WHERE s.rowid = ".$id;
468
+		$sql .= " fk_user_creat, fk_user_modif";
469
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
470
+		$sql .= " WHERE s.rowid = ".$id;
471 471
 
472
-		$result=$this->db->query($sql);
472
+		$result = $this->db->query($sql);
473 473
 		if ($result)
474 474
 		{
475 475
 			if ($this->db->num_rows($result))
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 				if ($obj->fk_user_creat) {
482 482
 					$cuser = new User($this->db);
483 483
 					$cuser->fetch($obj->fk_user_creat);
484
-					$this->user_creation     = $cuser;
484
+					$this->user_creation = $cuser;
485 485
 				}
486 486
 
487 487
 				if ($obj->fk_user_modif) {
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 					$muser->fetch($obj->fk_user_modif);
490 490
 					$this->user_modification = $muser;
491 491
 				}
492
-				$this->ref			     = $obj->name;
492
+				$this->ref = $obj->name;
493 493
 				$this->date_creation     = $this->db->jdate($obj->date_creation);
494 494
 				$this->date_modification = $this->db->jdate($obj->date_modification);
495 495
 			}
Please login to merge, or discard this patch.
Braces   +17 added lines, -24 removed lines patch added patch discarded remove patch
@@ -118,15 +118,13 @@  discard block
 block discarded – undo
118 118
 					dol_syslog(get_class($this)."::create success id=".$this->id);
119 119
 					$this->db->commit();
120 120
 					return 0;
121
-				}
122
-				else
121
+				} else
123 122
 				{
124 123
 					dol_syslog(get_class($this)."::create echec update");
125 124
 					$this->db->rollback();
126 125
 					return -3;
127 126
 				}
128
-			}
129
-			else
127
+			} else
130 128
 
131 129
 			{
132 130
 				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
@@ -138,8 +136,7 @@  discard block
 block discarded – undo
138 136
 				$this->db->rollback();
139 137
 				return -2;
140 138
 			}
141
-		}
142
-		else
139
+		} else
143 140
 		{
144 141
 			$this->db->rollback();
145 142
 			dol_syslog(get_class($this)."::create echec verify sql=$sql");
@@ -213,7 +210,9 @@  discard block
 block discarded – undo
213 210
 			$sql.= ", note = ".($this->note?"'".$this->db->escape($this->note)."'":"null");
214 211
 			$sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
215 212
 			$sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
216
-			if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
213
+			if ($user) {
214
+			    $sql .= ",fk_user_modif = '".$user->id."'";
215
+			}
217 216
 			$sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $this->db->escape($id) ."'";
218 217
 
219 218
 			dol_syslog(get_class($this)."::Update", LOG_DEBUG);
@@ -223,16 +222,14 @@  discard block
 block discarded – undo
223 222
 				dol_syslog(get_class($this)."::Update success");
224 223
 				$this->db->commit();
225 224
 				return 1;
226
-			}
227
-			else
225
+			} else
228 226
 			{
229 227
 				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
230 228
 				{
231 229
 
232 230
 					$this->error=$langs->trans("ErrorDuplicateField",$this->name);
233 231
 					$result=-1;
234
-				}
235
-				else
232
+				} else
236 233
 				{
237 234
 					$this->error=$this->db->lasterror();
238 235
 					$result=-2;
@@ -319,20 +316,17 @@  discard block
 block discarded – undo
319 316
 					}
320 317
 					$this->db->free($resql);
321 318
 					return $num;
322
-				}
323
-				else
319
+				} else
324 320
 				{
325 321
 					dol_syslog(get_class($this).'::Fetch Erreur: aucune adresse', LOG_ERR);
326 322
 					return 0;
327 323
 				}
328
-			}
329
-			else
324
+			} else
330 325
 			{
331 326
 				dol_syslog(get_class($this).'::Fetch Erreur: societe inconnue', LOG_ERR);
332 327
 				return -1;
333 328
 			}
334
-		}
335
-		else
329
+		} else
336 330
 		{
337 331
 			$this->error=$this->db->error();
338 332
 		}
@@ -386,8 +380,7 @@  discard block
 block discarded – undo
386 380
 				$this->note				= $obj->note;
387 381
 
388 382
 				$result = 1;
389
-			}
390
-			else
383
+			} else
391 384
 			{
392 385
 				dol_syslog('Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql);
393 386
 				$this->error='Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql;
@@ -395,8 +388,7 @@  discard block
 block discarded – undo
395 388
 			}
396 389
 
397 390
 			$this->db->free($resql);
398
-		}
399
-		else
391
+		} else
400 392
 		{
401 393
 			dol_syslog('Erreur Societe::Fetch echec', LOG_DEBUG);
402 394
 			dol_syslog('Erreur Societe::Fetch '.$this->db->error());
@@ -450,7 +442,9 @@  discard block
 block discarded – undo
450 442
         $link = '<a href="'.DOL_URL_ROOT.'/comm/address.php?id='.$this->id.'&socid='.$this->socid.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
451 443
 		$linkend='</a>';
452 444
 
453
-        if ($withpicto) $result.=($link.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$linkend.' ');
445
+        if ($withpicto) {
446
+            $result.=($link.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$linkend.' ');
447
+        }
454 448
 		$result.=$link.$this->label.$linkend;
455 449
 		return $result;
456 450
 	}
@@ -495,8 +489,7 @@  discard block
 block discarded – undo
495 489
 			}
496 490
 
497 491
 			$this->db->free($result);
498
-		}
499
-		else
492
+		} else
500 493
 		{
501 494
 			dol_print_error($this->db);
502 495
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/companybankaccount.class.php 3 patches
Indentation   +381 added lines, -381 removed lines patch added patch discarded remove patch
@@ -33,386 +33,386 @@
 block discarded – undo
33 33
  */
34 34
 class CompanyBankAccount extends Account
35 35
 {
36
-	var $socid;
37
-
38
-	var $default_rib;
39
-	var $frstrecur;
40
-	var $rum;
41
-	var $date_rum;
42
-
43
-	var $datec;
44
-	var $datem;
45
-
46
-
47
-	/**
48
-	 *  Constructor
49
-	 *
50
-	 *  @param      DoliDB		$db      Database handler
51
-	 */
52
-	public function __construct(DoliDB $db)
53
-	{
54
-		$this->db = $db;
55
-
56
-		$this->socid = 0;
57
-		$this->solde = 0;
58
-		$this->error_number = 0;
59
-		$this->default_rib = 0;
60
-	}
61
-
62
-
63
-	/**
64
-	 * Create bank information record
65
-	 *
66
-	 * @param   User   $user		User
67
-	 * @param   int    $notrigger   1=Disable triggers
68
-	 * @return	int					<0 if KO, >= 0 if OK
69
-	 */
70
-	function create(User $user = null, $notrigger=0)
71
-	{
72
-		$now	= dol_now();
73
-		$error	= 0;
74
-		// Correct default_rib to be sure to have always one default
75
-		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
76
-   		$result = $this->db->query($sql);
77
-		if ($result)
78
-		{
79
-			$numrows=$this->db->num_rows($result);
80
-			if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
81
-			if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
82
-		}
83
-
84
-		$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
85
-		$sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
86
-		$resql=$this->db->query($sql);
87
-		if ($resql)
88
-		{
89
-			if ($this->db->affected_rows($resql))
90
-			{
91
-				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
92
-
93
-				if (! $notrigger)
94
-				{
95
-				   	// Call trigger
96
-					$result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
97
-					if ($result < 0) $error++;
98
-					// End call triggers
99
-
100
-					if (! $error)
101
-					{
102
-						return 1;
103
-					}
104
-					else
105
-					{
106
-						return 0;
107
-					}
108
-				}
109
-				else
110
-				{
111
-					return 1;
112
-				}
113
-			}
114
-		}
115
-		else
116
-		{
117
-			print $this->db->error();
118
-			return 0;
119
-		}
120
-	}
121
-
122
-	/**
123
-	 *	Update bank account
124
-	 *
125
-	 *	@param	User	$user	     Object user
126
-	 *  @param  int     $notrigger   1=Disable triggers
127
-	 *	@return	int				     <=0 if KO, >0 if OK
128
-	 */
129
-	function update(User $user = null, $notrigger = 0)
130
-	{
131
-		global $conf;
132
-		$error = 0;
133
-
134
-		if (! $this->id) return -1;
135
-
136
-		if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
137
-		if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
138
-
139
-		$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
140
-		$sql.= " bank = '" .$this->db->escape($this->bank)."'";
141
-		$sql.= ",code_banque='".$this->db->escape($this->code_banque)."'";
142
-		$sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
143
-		$sql.= ",number='".$this->db->escape($this->number)."'";
144
-		$sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'";
145
-		$sql.= ",bic='".$this->db->escape($this->bic)."'";
146
-		$sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'";
147
-		$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
148
-		$sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
149
-		$sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
150
-		$sql.= ",default_rib = ".$this->default_rib;
151
-		if ($conf->prelevement->enabled)
152
-		{
153
-			$sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
154
-			$sql.= ",rum = '".$this->db->escape($this->rum)."'";
155
-			$sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
156
-		}
157
-		if (trim($this->label) != '')
158
-			$sql.= ",label = '".$this->db->escape($this->label)."'";
159
-		else
160
-			$sql.= ",label = NULL";
161
-		$sql.= " WHERE rowid = ".$this->id;
162
-
163
-		$result = $this->db->query($sql);
164
-		if ($result)
165
-		{
166
-
167
-
168
-		if (! $notrigger)
169
-		{
170
-			// Call trigger
171
-			$result=$this->call_trigger('COMPANY_RIB_MODIFY',$user);
172
-			if ($result < 0) $error++;
173
-			// End call triggers
174
-			if(! $error )
175
-			{
176
-				return 1;
177
-			}
178
-			else
179
-			{
180
-				return -1;
181
-			}
182
-		}
183
-		else
184
-		{
185
-			return 1;
186
-		}
187
-		}
188
-		else
189
-		{
190
-			dol_print_error($this->db);
191
-			return -1;
192
-		}
193
-	}
194
-
195
-	/**
196
-	 * 	Load record from database
197
-	 *
198
-	 *	@param	int		$id			Id of record
199
-	 * 	@param	int		$socid		Id of company. If this is filled, function will return the first entry found (matching $default and $type)
200
-	 *  @param	int		$default	If id of company filled, we say if we want first record among all (-1), default record (1) or non default record (0)
201
-	 *  @param	int		$type		If id of company filled, we say if we want record of this type only
202
-	 * 	@return	int					<0 if KO, >0 if OK
203
-	 */
204
-	function fetch($id, $socid=0, $default=1, $type='ban')
205
-	{
206
-		if (empty($id) && empty($socid)) return -1;
207
-
208
-		$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
209
-		$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
-		if ($id)    $sql.= " WHERE rowid = ".$id;
212
-		if ($socid)
213
-		{
214
-			$sql.= " WHERE fk_soc  = ".$socid;
215
-			if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default);
216
-			if ($type) $sql.= " AND type ='".$this->db->escape($type)."'";
217
-		}
218
-
219
-		$resql = $this->db->query($sql);
220
-		if ($resql)
221
-		{
222
-			if ($this->db->num_rows($resql))
223
-			{
224
-				$obj = $this->db->fetch_object($resql);
225
-
226
-				$this->ref             = $obj->fk_soc.'-'.$obj->label;      // Generate an artificial ref
227
-
228
-				$this->id			   = $obj->rowid;
229
-				$this->type			   = $obj->type;
230
-				$this->socid           = $obj->fk_soc;
231
-				$this->bank            = $obj->bank;
232
-				$this->code_banque     = $obj->code_banque;
233
-				$this->code_guichet    = $obj->code_guichet;
234
-				$this->number          = $obj->number;
235
-				$this->cle_rib         = $obj->cle_rib;
236
-				$this->bic             = $obj->bic;
237
-				$this->iban		       = $obj->iban;
238
-				$this->domiciliation   = $obj->domiciliation;
239
-				$this->proprio         = $obj->proprio;
240
-				$this->owner_address   = $obj->owner_address;
241
-				$this->label           = $obj->label;
242
-				$this->default_rib     = $obj->default_rib;
243
-				$this->datec           = $this->db->jdate($obj->datec);
244
-				$this->datem           = $this->db->jdate($obj->datem);
245
-				$this->rum             = $obj->rum;
246
-				$this->frstrecur       = $obj->frstrecur;
247
-			}
248
-			$this->db->free($resql);
249
-
250
-			return 1;
251
-		}
252
-		else
253
-		{
254
-			dol_print_error($this->db);
255
-			return -1;
256
-		}
257
-	}
258
-
259
-	/**
260
-	 *  Delete a rib from database
261
-	 *
262
-	 *	@param		User	$user		User deleting
263
-	 *	@param  	int		$notrigger	1=Disable triggers
264
-	 *  @return		int		            <0 if KO, >0 if OK
265
-	 */
266
-	function delete(User $user = null, $notrigger=0)
267
-	{
268
-		global $conf;
269
-
270
-		$error = 0;
271
-
272
-		dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
273
-
274
-		$this->db->begin();
275
-
276
-		if (! $error && ! $notrigger)
277
-		{
278
-			// Call trigger
279
-			$result=$this->call_trigger('COMPANY_RIB_DELETE',$user);
280
-			if ($result < 0) $error++;
281
-			// End call triggers
282
-		}
283
-
284
-		if (! $error)
285
-		{
286
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
287
-			$sql .= " WHERE rowid  = " . $this->id;
288
-
289
-			if (! $this->db->query($sql))
290
-			{
291
-				$error++;
292
-				$this->errors[]=$this->db->lasterror();
293
-			}
294
-		}
295
-
296
-		if (! $error)
297
-		{
298
-			$this->db->commit();
299
-			return 1;
300
-		}
301
-		else
302
-		{
303
-			$this->db->rollback();
304
-			return -1*$error;
305
-		}
306
-	}
307
-
308
-	/**
309
-	 * Return RIB
310
-	 *
311
-	 * @param   boolean     $displayriblabel     Prepend or Hide Label
312
-	 * @return	string		RIB
313
-	 */
314
-	public function getRibLabel($displayriblabel = true)
315
-	{
316
-		$rib = '';
317
-
318
-		if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
319
-
320
-			if ($this->label && $displayriblabel) {
321
-				$rib = $this->label." : ";
322
-			}
323
-
324
-			$rib .= (string) $this;
325
-		}
326
-
327
-		return $rib;
328
-	}
329
-
330
-	/**
331
-	 * Set a BAN as Default
332
-	 *
333
-	 * @param   int     $rib    RIB id
334
-	 * @return  int             0 if KO, 1 if OK
335
-	 */
336
-	function setAsDefault($rib=0)
337
-	{
338
-		$sql1 = "SELECT rowid as id, fk_soc  FROM ".MAIN_DB_PREFIX."societe_rib";
339
-		$sql1.= " WHERE rowid = ".($rib?$rib:$this->id);
340
-
341
-		dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
342
-		$result1 = $this->db->query($sql1);
343
-		if ($result1)
344
-		{
345
-			if ($this->db->num_rows($result1) == 0)
346
-			{
347
-				return 0;
348
-			}
349
-			else
350
-			{
351
-				$obj = $this->db->fetch_object($result1);
352
-
353
-				$this->db->begin();
354
-
355
-				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
356
-				$sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
357
-				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
358
-				$result2 = $this->db->query($sql2);
359
-
360
-				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
361
-				$sql3.= " WHERE rowid = ".$obj->id;
362
-				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
363
-				$result3 = $this->db->query($sql3);
364
-
365
-				if (!$result2 || !$result3)
366
-				{
367
-					dol_print_error($this->db);
368
-					$this->db->rollback();
369
-					return -1;
370
-				}
371
-				else
372
-				{
373
-					$this->db->commit();
374
-					return 1;
375
-				}
376
-			}
377
-		}
378
-		else
379
-		{
380
-			dol_print_error($this->db);
381
-			return -1;
382
-		}
383
-	}
384
-
385
-	/**
386
-	 *  Initialise an instance with random values.
387
-	 *  Used to build previews or test instances.
388
-	 *	id must be 0 if object instance is a specimen.
389
-	 *
390
-	 *  @return	void
391
-	 */
392
-	function initAsSpecimen()
393
-	{
394
-		$this->specimen        = 1;
395
-		$this->ref             = 'CBA';
396
-		$this->label           = 'CustomerCorp Bank account';
397
-		$this->bank            = 'CustomerCorp Bank';
398
-		$this->courant         = Account::TYPE_CURRENT;
399
-		$this->clos            = Account::STATUS_OPEN;
400
-		$this->code_banque     = '123';
401
-		$this->code_guichet    = '456';
402
-		$this->number          = 'CUST12345';
403
-		$this->cle_rib         = 50;
404
-		$this->bic             = 'CC12';
405
-		$this->iban            = 'FR999999999';
406
-		$this->domiciliation   = 'Bank address of customer corp';
407
-		$this->proprio         = 'Owner';
408
-		$this->owner_address   = 'Owner address';
409
-		$this->country_id      = 1;
410
-
411
-		$this->rum             = 'UMR-CU1212-0007-5-1475405262';
412
-		$this->date_rum        =dol_now() - 10000;
413
-		$this->frstrecur       = 'FRST';
414
-
415
-		$this->socid = 0;
416
-	}
36
+    var $socid;
37
+
38
+    var $default_rib;
39
+    var $frstrecur;
40
+    var $rum;
41
+    var $date_rum;
42
+
43
+    var $datec;
44
+    var $datem;
45
+
46
+
47
+    /**
48
+     *  Constructor
49
+     *
50
+     *  @param      DoliDB		$db      Database handler
51
+     */
52
+    public function __construct(DoliDB $db)
53
+    {
54
+        $this->db = $db;
55
+
56
+        $this->socid = 0;
57
+        $this->solde = 0;
58
+        $this->error_number = 0;
59
+        $this->default_rib = 0;
60
+    }
61
+
62
+
63
+    /**
64
+     * Create bank information record
65
+     *
66
+     * @param   User   $user		User
67
+     * @param   int    $notrigger   1=Disable triggers
68
+     * @return	int					<0 if KO, >= 0 if OK
69
+     */
70
+    function create(User $user = null, $notrigger=0)
71
+    {
72
+        $now	= dol_now();
73
+        $error	= 0;
74
+        // Correct default_rib to be sure to have always one default
75
+        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
76
+            $result = $this->db->query($sql);
77
+        if ($result)
78
+        {
79
+            $numrows=$this->db->num_rows($result);
80
+            if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
81
+            if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
82
+        }
83
+
84
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
85
+        $sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
86
+        $resql=$this->db->query($sql);
87
+        if ($resql)
88
+        {
89
+            if ($this->db->affected_rows($resql))
90
+            {
91
+                $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
92
+
93
+                if (! $notrigger)
94
+                {
95
+                        // Call trigger
96
+                    $result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
97
+                    if ($result < 0) $error++;
98
+                    // End call triggers
99
+
100
+                    if (! $error)
101
+                    {
102
+                        return 1;
103
+                    }
104
+                    else
105
+                    {
106
+                        return 0;
107
+                    }
108
+                }
109
+                else
110
+                {
111
+                    return 1;
112
+                }
113
+            }
114
+        }
115
+        else
116
+        {
117
+            print $this->db->error();
118
+            return 0;
119
+        }
120
+    }
121
+
122
+    /**
123
+     *	Update bank account
124
+     *
125
+     *	@param	User	$user	     Object user
126
+     *  @param  int     $notrigger   1=Disable triggers
127
+     *	@return	int				     <=0 if KO, >0 if OK
128
+     */
129
+    function update(User $user = null, $notrigger = 0)
130
+    {
131
+        global $conf;
132
+        $error = 0;
133
+
134
+        if (! $this->id) return -1;
135
+
136
+        if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
137
+        if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
138
+
139
+        $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
140
+        $sql.= " bank = '" .$this->db->escape($this->bank)."'";
141
+        $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'";
142
+        $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
143
+        $sql.= ",number='".$this->db->escape($this->number)."'";
144
+        $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'";
145
+        $sql.= ",bic='".$this->db->escape($this->bic)."'";
146
+        $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'";
147
+        $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
148
+        $sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
149
+        $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
150
+        $sql.= ",default_rib = ".$this->default_rib;
151
+        if ($conf->prelevement->enabled)
152
+        {
153
+            $sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
154
+            $sql.= ",rum = '".$this->db->escape($this->rum)."'";
155
+            $sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
156
+        }
157
+        if (trim($this->label) != '')
158
+            $sql.= ",label = '".$this->db->escape($this->label)."'";
159
+        else
160
+            $sql.= ",label = NULL";
161
+        $sql.= " WHERE rowid = ".$this->id;
162
+
163
+        $result = $this->db->query($sql);
164
+        if ($result)
165
+        {
166
+
167
+
168
+        if (! $notrigger)
169
+        {
170
+            // Call trigger
171
+            $result=$this->call_trigger('COMPANY_RIB_MODIFY',$user);
172
+            if ($result < 0) $error++;
173
+            // End call triggers
174
+            if(! $error )
175
+            {
176
+                return 1;
177
+            }
178
+            else
179
+            {
180
+                return -1;
181
+            }
182
+        }
183
+        else
184
+        {
185
+            return 1;
186
+        }
187
+        }
188
+        else
189
+        {
190
+            dol_print_error($this->db);
191
+            return -1;
192
+        }
193
+    }
194
+
195
+    /**
196
+     * 	Load record from database
197
+     *
198
+     *	@param	int		$id			Id of record
199
+     * 	@param	int		$socid		Id of company. If this is filled, function will return the first entry found (matching $default and $type)
200
+     *  @param	int		$default	If id of company filled, we say if we want first record among all (-1), default record (1) or non default record (0)
201
+     *  @param	int		$type		If id of company filled, we say if we want record of this type only
202
+     * 	@return	int					<0 if KO, >0 if OK
203
+     */
204
+    function fetch($id, $socid=0, $default=1, $type='ban')
205
+    {
206
+        if (empty($id) && empty($socid)) return -1;
207
+
208
+        $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
209
+        $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
+        if ($id)    $sql.= " WHERE rowid = ".$id;
212
+        if ($socid)
213
+        {
214
+            $sql.= " WHERE fk_soc  = ".$socid;
215
+            if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default);
216
+            if ($type) $sql.= " AND type ='".$this->db->escape($type)."'";
217
+        }
218
+
219
+        $resql = $this->db->query($sql);
220
+        if ($resql)
221
+        {
222
+            if ($this->db->num_rows($resql))
223
+            {
224
+                $obj = $this->db->fetch_object($resql);
225
+
226
+                $this->ref             = $obj->fk_soc.'-'.$obj->label;      // Generate an artificial ref
227
+
228
+                $this->id			   = $obj->rowid;
229
+                $this->type			   = $obj->type;
230
+                $this->socid           = $obj->fk_soc;
231
+                $this->bank            = $obj->bank;
232
+                $this->code_banque     = $obj->code_banque;
233
+                $this->code_guichet    = $obj->code_guichet;
234
+                $this->number          = $obj->number;
235
+                $this->cle_rib         = $obj->cle_rib;
236
+                $this->bic             = $obj->bic;
237
+                $this->iban		       = $obj->iban;
238
+                $this->domiciliation   = $obj->domiciliation;
239
+                $this->proprio         = $obj->proprio;
240
+                $this->owner_address   = $obj->owner_address;
241
+                $this->label           = $obj->label;
242
+                $this->default_rib     = $obj->default_rib;
243
+                $this->datec           = $this->db->jdate($obj->datec);
244
+                $this->datem           = $this->db->jdate($obj->datem);
245
+                $this->rum             = $obj->rum;
246
+                $this->frstrecur       = $obj->frstrecur;
247
+            }
248
+            $this->db->free($resql);
249
+
250
+            return 1;
251
+        }
252
+        else
253
+        {
254
+            dol_print_error($this->db);
255
+            return -1;
256
+        }
257
+    }
258
+
259
+    /**
260
+     *  Delete a rib from database
261
+     *
262
+     *	@param		User	$user		User deleting
263
+     *	@param  	int		$notrigger	1=Disable triggers
264
+     *  @return		int		            <0 if KO, >0 if OK
265
+     */
266
+    function delete(User $user = null, $notrigger=0)
267
+    {
268
+        global $conf;
269
+
270
+        $error = 0;
271
+
272
+        dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
273
+
274
+        $this->db->begin();
275
+
276
+        if (! $error && ! $notrigger)
277
+        {
278
+            // Call trigger
279
+            $result=$this->call_trigger('COMPANY_RIB_DELETE',$user);
280
+            if ($result < 0) $error++;
281
+            // End call triggers
282
+        }
283
+
284
+        if (! $error)
285
+        {
286
+            $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
287
+            $sql .= " WHERE rowid  = " . $this->id;
288
+
289
+            if (! $this->db->query($sql))
290
+            {
291
+                $error++;
292
+                $this->errors[]=$this->db->lasterror();
293
+            }
294
+        }
295
+
296
+        if (! $error)
297
+        {
298
+            $this->db->commit();
299
+            return 1;
300
+        }
301
+        else
302
+        {
303
+            $this->db->rollback();
304
+            return -1*$error;
305
+        }
306
+    }
307
+
308
+    /**
309
+     * Return RIB
310
+     *
311
+     * @param   boolean     $displayriblabel     Prepend or Hide Label
312
+     * @return	string		RIB
313
+     */
314
+    public function getRibLabel($displayriblabel = true)
315
+    {
316
+        $rib = '';
317
+
318
+        if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
319
+
320
+            if ($this->label && $displayriblabel) {
321
+                $rib = $this->label." : ";
322
+            }
323
+
324
+            $rib .= (string) $this;
325
+        }
326
+
327
+        return $rib;
328
+    }
329
+
330
+    /**
331
+     * Set a BAN as Default
332
+     *
333
+     * @param   int     $rib    RIB id
334
+     * @return  int             0 if KO, 1 if OK
335
+     */
336
+    function setAsDefault($rib=0)
337
+    {
338
+        $sql1 = "SELECT rowid as id, fk_soc  FROM ".MAIN_DB_PREFIX."societe_rib";
339
+        $sql1.= " WHERE rowid = ".($rib?$rib:$this->id);
340
+
341
+        dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
342
+        $result1 = $this->db->query($sql1);
343
+        if ($result1)
344
+        {
345
+            if ($this->db->num_rows($result1) == 0)
346
+            {
347
+                return 0;
348
+            }
349
+            else
350
+            {
351
+                $obj = $this->db->fetch_object($result1);
352
+
353
+                $this->db->begin();
354
+
355
+                $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
356
+                $sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
357
+                dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
358
+                $result2 = $this->db->query($sql2);
359
+
360
+                $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
361
+                $sql3.= " WHERE rowid = ".$obj->id;
362
+                dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
363
+                $result3 = $this->db->query($sql3);
364
+
365
+                if (!$result2 || !$result3)
366
+                {
367
+                    dol_print_error($this->db);
368
+                    $this->db->rollback();
369
+                    return -1;
370
+                }
371
+                else
372
+                {
373
+                    $this->db->commit();
374
+                    return 1;
375
+                }
376
+            }
377
+        }
378
+        else
379
+        {
380
+            dol_print_error($this->db);
381
+            return -1;
382
+        }
383
+    }
384
+
385
+    /**
386
+     *  Initialise an instance with random values.
387
+     *  Used to build previews or test instances.
388
+     *	id must be 0 if object instance is a specimen.
389
+     *
390
+     *  @return	void
391
+     */
392
+    function initAsSpecimen()
393
+    {
394
+        $this->specimen        = 1;
395
+        $this->ref             = 'CBA';
396
+        $this->label           = 'CustomerCorp Bank account';
397
+        $this->bank            = 'CustomerCorp Bank';
398
+        $this->courant         = Account::TYPE_CURRENT;
399
+        $this->clos            = Account::STATUS_OPEN;
400
+        $this->code_banque     = '123';
401
+        $this->code_guichet    = '456';
402
+        $this->number          = 'CUST12345';
403
+        $this->cle_rib         = 50;
404
+        $this->bic             = 'CC12';
405
+        $this->iban            = 'FR999999999';
406
+        $this->domiciliation   = 'Bank address of customer corp';
407
+        $this->proprio         = 'Owner';
408
+        $this->owner_address   = 'Owner address';
409
+        $this->country_id      = 1;
410
+
411
+        $this->rum             = 'UMR-CU1212-0007-5-1475405262';
412
+        $this->date_rum        =dol_now() - 10000;
413
+        $this->frstrecur       = 'FRST';
414
+
415
+        $this->socid = 0;
416
+    }
417 417
 }
418 418
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *		\brief      File of class to manage bank accounts description of third parties
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
28
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 	 * @param   int    $notrigger   1=Disable triggers
68 68
 	 * @return	int					<0 if KO, >= 0 if OK
69 69
 	 */
70
-	function create(User $user = null, $notrigger=0)
70
+	function create(User $user = null, $notrigger = 0)
71 71
 	{
72 72
 		$now	= dol_now();
73
-		$error	= 0;
73
+		$error = 0;
74 74
 		// Correct default_rib to be sure to have always one default
75 75
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
76 76
    		$result = $this->db->query($sql);
77 77
 		if ($result)
78 78
 		{
79
-			$numrows=$this->db->num_rows($result);
79
+			$numrows = $this->db->num_rows($result);
80 80
 			if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
81 81
 			if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
82 82
 		}
83 83
 
84 84
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
85
-		$sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
86
-		$resql=$this->db->query($sql);
85
+		$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
86
+		$resql = $this->db->query($sql);
87 87
 		if ($resql)
88 88
 		{
89 89
 			if ($this->db->affected_rows($resql))
90 90
 			{
91 91
 				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
92 92
 
93
-				if (! $notrigger)
93
+				if (!$notrigger)
94 94
 				{
95 95
 				   	// Call trigger
96
-					$result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
96
+					$result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
97 97
 					if ($result < 0) $error++;
98 98
 					// End call triggers
99 99
 
100
-					if (! $error)
100
+					if (!$error)
101 101
 					{
102 102
 						return 1;
103 103
 					}
@@ -131,47 +131,47 @@  discard block
 block discarded – undo
131 131
 		global $conf;
132 132
 		$error = 0;
133 133
 
134
-		if (! $this->id) return -1;
134
+		if (!$this->id) return -1;
135 135
 
136 136
 		if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
137 137
 		if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
138 138
 
139 139
 		$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
140
-		$sql.= " bank = '" .$this->db->escape($this->bank)."'";
141
-		$sql.= ",code_banque='".$this->db->escape($this->code_banque)."'";
142
-		$sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
143
-		$sql.= ",number='".$this->db->escape($this->number)."'";
144
-		$sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'";
145
-		$sql.= ",bic='".$this->db->escape($this->bic)."'";
146
-		$sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'";
147
-		$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
148
-		$sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
149
-		$sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
150
-		$sql.= ",default_rib = ".$this->default_rib;
140
+		$sql .= " bank = '".$this->db->escape($this->bank)."'";
141
+		$sql .= ",code_banque='".$this->db->escape($this->code_banque)."'";
142
+		$sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
143
+		$sql .= ",number='".$this->db->escape($this->number)."'";
144
+		$sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'";
145
+		$sql .= ",bic='".$this->db->escape($this->bic)."'";
146
+		$sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'";
147
+		$sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
148
+		$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
149
+		$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
150
+		$sql .= ",default_rib = ".$this->default_rib;
151 151
 		if ($conf->prelevement->enabled)
152 152
 		{
153
-			$sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
154
-			$sql.= ",rum = '".$this->db->escape($this->rum)."'";
155
-			$sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
153
+			$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
154
+			$sql .= ",rum = '".$this->db->escape($this->rum)."'";
155
+			$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
156 156
 		}
157 157
 		if (trim($this->label) != '')
158
-			$sql.= ",label = '".$this->db->escape($this->label)."'";
158
+			$sql .= ",label = '".$this->db->escape($this->label)."'";
159 159
 		else
160
-			$sql.= ",label = NULL";
161
-		$sql.= " WHERE rowid = ".$this->id;
160
+			$sql .= ",label = NULL";
161
+		$sql .= " WHERE rowid = ".$this->id;
162 162
 
163 163
 		$result = $this->db->query($sql);
164 164
 		if ($result)
165 165
 		{
166 166
 
167 167
 
168
-		if (! $notrigger)
168
+		if (!$notrigger)
169 169
 		{
170 170
 			// Call trigger
171
-			$result=$this->call_trigger('COMPANY_RIB_MODIFY',$user);
171
+			$result = $this->call_trigger('COMPANY_RIB_MODIFY', $user);
172 172
 			if ($result < 0) $error++;
173 173
 			// End call triggers
174
-			if(! $error )
174
+			if (!$error)
175 175
 			{
176 176
 				return 1;
177 177
 			}
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
 	 *  @param	int		$type		If id of company filled, we say if we want record of this type only
202 202
 	 * 	@return	int					<0 if KO, >0 if OK
203 203
 	 */
204
-	function fetch($id, $socid=0, $default=1, $type='ban')
204
+	function fetch($id, $socid = 0, $default = 1, $type = 'ban')
205 205
 	{
206 206
 		if (empty($id) && empty($socid)) return -1;
207 207
 
208 208
 		$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
209
-		$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
-		if ($id)    $sql.= " WHERE rowid = ".$id;
209
+		$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
+		if ($id)    $sql .= " WHERE rowid = ".$id;
212 212
 		if ($socid)
213 213
 		{
214
-			$sql.= " WHERE fk_soc  = ".$socid;
215
-			if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default);
216
-			if ($type) $sql.= " AND type ='".$this->db->escape($type)."'";
214
+			$sql .= " WHERE fk_soc  = ".$socid;
215
+			if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default);
216
+			if ($type) $sql .= " AND type ='".$this->db->escape($type)."'";
217 217
 		}
218 218
 
219 219
 		$resql = $this->db->query($sql);
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 			{
224 224
 				$obj = $this->db->fetch_object($resql);
225 225
 
226
-				$this->ref             = $obj->fk_soc.'-'.$obj->label;      // Generate an artificial ref
226
+				$this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
227 227
 
228
-				$this->id			   = $obj->rowid;
229
-				$this->type			   = $obj->type;
228
+				$this->id = $obj->rowid;
229
+				$this->type = $obj->type;
230 230
 				$this->socid           = $obj->fk_soc;
231 231
 				$this->bank            = $obj->bank;
232 232
 				$this->code_banque     = $obj->code_banque;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				$this->number          = $obj->number;
235 235
 				$this->cle_rib         = $obj->cle_rib;
236 236
 				$this->bic             = $obj->bic;
237
-				$this->iban		       = $obj->iban;
237
+				$this->iban = $obj->iban;
238 238
 				$this->domiciliation   = $obj->domiciliation;
239 239
 				$this->proprio         = $obj->proprio;
240 240
 				$this->owner_address   = $obj->owner_address;
@@ -263,37 +263,37 @@  discard block
 block discarded – undo
263 263
 	 *	@param  	int		$notrigger	1=Disable triggers
264 264
 	 *  @return		int		            <0 if KO, >0 if OK
265 265
 	 */
266
-	function delete(User $user = null, $notrigger=0)
266
+	function delete(User $user = null, $notrigger = 0)
267 267
 	{
268 268
 		global $conf;
269 269
 
270 270
 		$error = 0;
271 271
 
272
-		dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
272
+		dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG);
273 273
 
274 274
 		$this->db->begin();
275 275
 
276
-		if (! $error && ! $notrigger)
276
+		if (!$error && !$notrigger)
277 277
 		{
278 278
 			// Call trigger
279
-			$result=$this->call_trigger('COMPANY_RIB_DELETE',$user);
279
+			$result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
280 280
 			if ($result < 0) $error++;
281 281
 			// End call triggers
282 282
 		}
283 283
 
284
-		if (! $error)
284
+		if (!$error)
285 285
 		{
286
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
287
-			$sql .= " WHERE rowid  = " . $this->id;
286
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
287
+			$sql .= " WHERE rowid  = ".$this->id;
288 288
 
289
-			if (! $this->db->query($sql))
289
+			if (!$this->db->query($sql))
290 290
 			{
291 291
 				$error++;
292
-				$this->errors[]=$this->db->lasterror();
292
+				$this->errors[] = $this->db->lasterror();
293 293
 			}
294 294
 		}
295 295
 
296
-		if (! $error)
296
+		if (!$error)
297 297
 		{
298 298
 			$this->db->commit();
299 299
 			return 1;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		else
302 302
 		{
303 303
 			$this->db->rollback();
304
-			return -1*$error;
304
+			return -1 * $error;
305 305
 		}
306 306
 	}
307 307
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	{
316 316
 		$rib = '';
317 317
 
318
-		if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
318
+		if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic) {
319 319
 
320 320
 			if ($this->label && $displayriblabel) {
321 321
 				$rib = $this->label." : ";
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 	 * @param   int     $rib    RIB id
334 334
 	 * @return  int             0 if KO, 1 if OK
335 335
 	 */
336
-	function setAsDefault($rib=0)
336
+	function setAsDefault($rib = 0)
337 337
 	{
338 338
 		$sql1 = "SELECT rowid as id, fk_soc  FROM ".MAIN_DB_PREFIX."societe_rib";
339
-		$sql1.= " WHERE rowid = ".($rib?$rib:$this->id);
339
+		$sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id);
340 340
 
341 341
 		dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
342 342
 		$result1 = $this->db->query($sql1);
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 				$this->db->begin();
354 354
 
355 355
 				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
356
-				$sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
356
+				$sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
357 357
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
358 358
 				$result2 = $this->db->query($sql2);
359 359
 
360 360
 				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
361
-				$sql3.= " WHERE rowid = ".$obj->id;
361
+				$sql3 .= " WHERE rowid = ".$obj->id;
362 362
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
363 363
 				$result3 = $this->db->query($sql3);
364 364
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		$this->country_id      = 1;
410 410
 
411 411
 		$this->rum             = 'UMR-CU1212-0007-5-1475405262';
412
-		$this->date_rum        =dol_now() - 10000;
412
+		$this->date_rum        = dol_now() - 10000;
413 413
 		$this->frstrecur       = 'FRST';
414 414
 
415 415
 		$this->socid = 0;
Please login to merge, or discard this patch.
Braces   +52 added lines, -38 removed lines patch added patch discarded remove patch
@@ -77,8 +77,12 @@  discard block
 block discarded – undo
77 77
 		if ($result)
78 78
 		{
79 79
 			$numrows=$this->db->num_rows($result);
80
-			if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
81
-			if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
80
+			if ($this->default_rib && $numrows > 0) {
81
+			    $this->default_rib = 0;
82
+			}
83
+			if (empty($this->default_rib) && $numrows == 0) {
84
+			    $this->default_rib = 1;
85
+			}
82 86
 		}
83 87
 
84 88
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
@@ -94,25 +98,24 @@  discard block
 block discarded – undo
94 98
 				{
95 99
 				   	// Call trigger
96 100
 					$result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
97
-					if ($result < 0) $error++;
101
+					if ($result < 0) {
102
+					    $error++;
103
+					}
98 104
 					// End call triggers
99 105
 
100 106
 					if (! $error)
101 107
 					{
102 108
 						return 1;
103
-					}
104
-					else
109
+					} else
105 110
 					{
106 111
 						return 0;
107 112
 					}
108
-				}
109
-				else
113
+				} else
110 114
 				{
111 115
 					return 1;
112 116
 				}
113 117
 			}
114
-		}
115
-		else
118
+		} else
116 119
 		{
117 120
 			print $this->db->error();
118 121
 			return 0;
@@ -131,10 +134,16 @@  discard block
 block discarded – undo
131 134
 		global $conf;
132 135
 		$error = 0;
133 136
 
134
-		if (! $this->id) return -1;
137
+		if (! $this->id) {
138
+		    return -1;
139
+		}
135 140
 
136
-		if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
137
-		if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
141
+		if (dol_strlen($this->domiciliation) > 255) {
142
+		    $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
143
+		}
144
+		if (dol_strlen($this->owner_address) > 255) {
145
+		    $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
146
+		}
138 147
 
139 148
 		$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
140 149
 		$sql.= " bank = '" .$this->db->escape($this->bank)."'";
@@ -154,10 +163,11 @@  discard block
 block discarded – undo
154 163
 			$sql.= ",rum = '".$this->db->escape($this->rum)."'";
155 164
 			$sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
156 165
 		}
157
-		if (trim($this->label) != '')
158
-			$sql.= ",label = '".$this->db->escape($this->label)."'";
159
-		else
160
-			$sql.= ",label = NULL";
166
+		if (trim($this->label) != '') {
167
+					$sql.= ",label = '".$this->db->escape($this->label)."'";
168
+		} else {
169
+					$sql.= ",label = NULL";
170
+		}
161 171
 		$sql.= " WHERE rowid = ".$this->id;
162 172
 
163 173
 		$result = $this->db->query($sql);
@@ -169,23 +179,22 @@  discard block
 block discarded – undo
169 179
 		{
170 180
 			// Call trigger
171 181
 			$result=$this->call_trigger('COMPANY_RIB_MODIFY',$user);
172
-			if ($result < 0) $error++;
182
+			if ($result < 0) {
183
+			    $error++;
184
+			}
173 185
 			// End call triggers
174 186
 			if(! $error )
175 187
 			{
176 188
 				return 1;
177
-			}
178
-			else
189
+			} else
179 190
 			{
180 191
 				return -1;
181 192
 			}
182
-		}
183
-		else
193
+		} else
184 194
 		{
185 195
 			return 1;
186 196
 		}
187
-		}
188
-		else
197
+		} else
189 198
 		{
190 199
 			dol_print_error($this->db);
191 200
 			return -1;
@@ -203,17 +212,25 @@  discard block
 block discarded – undo
203 212
 	 */
204 213
 	function fetch($id, $socid=0, $default=1, $type='ban')
205 214
 	{
206
-		if (empty($id) && empty($socid)) return -1;
215
+		if (empty($id) && empty($socid)) {
216
+		    return -1;
217
+		}
207 218
 
208 219
 		$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
209 220
 		$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210 221
 		$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
-		if ($id)    $sql.= " WHERE rowid = ".$id;
222
+		if ($id) {
223
+		    $sql.= " WHERE rowid = ".$id;
224
+		}
212 225
 		if ($socid)
213 226
 		{
214 227
 			$sql.= " WHERE fk_soc  = ".$socid;
215
-			if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default);
216
-			if ($type) $sql.= " AND type ='".$this->db->escape($type)."'";
228
+			if ($default > -1) {
229
+			    $sql.=" AND default_rib = ".$this->db->escape($default);
230
+			}
231
+			if ($type) {
232
+			    $sql.= " AND type ='".$this->db->escape($type)."'";
233
+			}
217 234
 		}
218 235
 
219 236
 		$resql = $this->db->query($sql);
@@ -248,8 +265,7 @@  discard block
 block discarded – undo
248 265
 			$this->db->free($resql);
249 266
 
250 267
 			return 1;
251
-		}
252
-		else
268
+		} else
253 269
 		{
254 270
 			dol_print_error($this->db);
255 271
 			return -1;
@@ -277,7 +293,9 @@  discard block
 block discarded – undo
277 293
 		{
278 294
 			// Call trigger
279 295
 			$result=$this->call_trigger('COMPANY_RIB_DELETE',$user);
280
-			if ($result < 0) $error++;
296
+			if ($result < 0) {
297
+			    $error++;
298
+			}
281 299
 			// End call triggers
282 300
 		}
283 301
 
@@ -297,8 +315,7 @@  discard block
 block discarded – undo
297 315
 		{
298 316
 			$this->db->commit();
299 317
 			return 1;
300
-		}
301
-		else
318
+		} else
302 319
 		{
303 320
 			$this->db->rollback();
304 321
 			return -1*$error;
@@ -345,8 +362,7 @@  discard block
 block discarded – undo
345 362
 			if ($this->db->num_rows($result1) == 0)
346 363
 			{
347 364
 				return 0;
348
-			}
349
-			else
365
+			} else
350 366
 			{
351 367
 				$obj = $this->db->fetch_object($result1);
352 368
 
@@ -367,15 +383,13 @@  discard block
 block discarded – undo
367 383
 					dol_print_error($this->db);
368 384
 					$this->db->rollback();
369 385
 					return -1;
370
-				}
371
-				else
386
+				} else
372 387
 				{
373 388
 					$this->db->commit();
374 389
 					return 1;
375 390
 				}
376 391
 			}
377
-		}
378
-		else
392
+		} else
379 393
 		{
380 394
 			dol_print_error($this->db);
381 395
 			return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/api_contacts.class.php 3 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -29,305 +29,305 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class Contacts extends DolibarrApi
31 31
 {
32
-	/**
33
-	 *
34
-	 * @var array   $FIELDS     Mandatory fields, checked when create and update object
35
-	 */
36
-	static $FIELDS = array(
37
-		'lastname',
38
-	);
39
-
40
-	/**
41
-	 * @var Contact $contact {@type Contact}
42
-	 */
43
-	public $contact;
44
-
45
-	/**
46
-	 * Constructor
47
-	 */
48
-	function __construct()
49
-	{
50
-		global $db, $conf;
51
-		$this->db = $db;
52
-
53
-		require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
54
-		require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
55
-
56
-		$this->contact = new Contact($this->db);
57
-	}
58
-
59
-	/**
60
-	 * Get properties of a contact object
61
-	 *
62
-	 * Return an array with contact informations
63
-	 *
64
-	 * @param 	int 	$id ID of contact
65
-	 * @return 	array|mixed data without useless information
66
-	 *
67
-	 * @throws 	RestException
68
-	 */
69
-	function get($id)
70
-	{
71
-		if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
72
-		{
73
-			throw new RestException(401, 'No permission to read contacts');
74
-		}
75
-
76
-		$result = $this->contact->fetch($id);
77
-		if (!$result)
78
-		{
79
-			throw new RestException(404, 'Contact not found');
80
-		}
81
-
82
-		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
83
-		{
84
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
85
-		}
86
-
87
-		return $this->_cleanObjectDatas($this->contact);
88
-	}
89
-
90
-	/**
91
-	 * List contacts
92
-	 *
93
-	 * Get a list of contacts
94
-	 *
95
-	 * @param string	$sortfield	        Sort field
96
-	 * @param string	$sortorder	        Sort order
97
-	 * @param int		$limit		        Limit for list
98
-	 * @param int		$page		        Page number
32
+    /**
33
+     *
34
+     * @var array   $FIELDS     Mandatory fields, checked when create and update object
35
+     */
36
+    static $FIELDS = array(
37
+        'lastname',
38
+    );
39
+
40
+    /**
41
+     * @var Contact $contact {@type Contact}
42
+     */
43
+    public $contact;
44
+
45
+    /**
46
+     * Constructor
47
+     */
48
+    function __construct()
49
+    {
50
+        global $db, $conf;
51
+        $this->db = $db;
52
+
53
+        require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
54
+        require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
55
+
56
+        $this->contact = new Contact($this->db);
57
+    }
58
+
59
+    /**
60
+     * Get properties of a contact object
61
+     *
62
+     * Return an array with contact informations
63
+     *
64
+     * @param 	int 	$id ID of contact
65
+     * @return 	array|mixed data without useless information
66
+     *
67
+     * @throws 	RestException
68
+     */
69
+    function get($id)
70
+    {
71
+        if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
72
+        {
73
+            throw new RestException(401, 'No permission to read contacts');
74
+        }
75
+
76
+        $result = $this->contact->fetch($id);
77
+        if (!$result)
78
+        {
79
+            throw new RestException(404, 'Contact not found');
80
+        }
81
+
82
+        if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
83
+        {
84
+            throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
85
+        }
86
+
87
+        return $this->_cleanObjectDatas($this->contact);
88
+    }
89
+
90
+    /**
91
+     * List contacts
92
+     *
93
+     * Get a list of contacts
94
+     *
95
+     * @param string	$sortfield	        Sort field
96
+     * @param string	$sortorder	        Sort order
97
+     * @param int		$limit		        Limit for list
98
+     * @param int		$page		        Page number
99 99
      * @param string   	$thirdparty_ids	    Thirdparty ids to filter contacts of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
100 100
      * @param string    $sqlfilters         Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
101
-	 * @return array                        Array of contact objects
101
+     * @return array                        Array of contact objects
102 102
      *
103
-	 * @throws RestException
103
+     * @throws RestException
104 104
      */
105 105
     function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
106 106
     {
107
-		global $db, $conf;
107
+        global $db, $conf;
108 108
 
109
-		$obj_ret = array();
109
+        $obj_ret = array();
110 110
 
111
-		if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
112
-		{
113
-		    throw new RestException(401, 'No permission to read contacts');
114
-		}
111
+        if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
112
+        {
113
+            throw new RestException(401, 'No permission to read contacts');
114
+        }
115 115
 
116 116
         // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
117
-		$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
118
-
119
-		// If the internal user must only see his customers, force searching by him
120
-		$search_sale = 0;
121
-		if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)
122
-			$search_sale = DolibarrApiAccess::$user->id;
123
-
124
-		$sql = "SELECT t.rowid";
125
-		$sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t";
126
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object = t.rowid";
127
-		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
128
-			// We need this table joined to the select in order to filter by sale
129
-			$sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
130
-		}
131
-		$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid";
132
-		$sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')';
133
-		if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")";
134
-
135
-		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
136
-			$sql.= " AND t.fk_soc = sc.fk_soc";
137
-		if ($search_sale > 0)
138
-			$sql.= " AND s.rowid = sc.fk_soc";  // Join for the needed table to filter by sale
139
-		// Insert sale filter
140
-		if ($search_sale > 0)
141
-		{
142
-			$sql .= " AND sc.fk_user = " . $search_sale;
143
-		}
144
-	    // Add sql filters
117
+        $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
118
+
119
+        // If the internal user must only see his customers, force searching by him
120
+        $search_sale = 0;
121
+        if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)
122
+            $search_sale = DolibarrApiAccess::$user->id;
123
+
124
+        $sql = "SELECT t.rowid";
125
+        $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t";
126
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object = t.rowid";
127
+        if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
128
+            // We need this table joined to the select in order to filter by sale
129
+            $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
130
+        }
131
+        $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid";
132
+        $sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')';
133
+        if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")";
134
+
135
+        if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
136
+            $sql.= " AND t.fk_soc = sc.fk_soc";
137
+        if ($search_sale > 0)
138
+            $sql.= " AND s.rowid = sc.fk_soc";  // Join for the needed table to filter by sale
139
+        // Insert sale filter
140
+        if ($search_sale > 0)
141
+        {
142
+            $sql .= " AND sc.fk_user = " . $search_sale;
143
+        }
144
+        // Add sql filters
145 145
         if ($sqlfilters)
146 146
         {
147 147
             if (! DolibarrApi::_checkFilters($sqlfilters))
148 148
             {
149 149
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
150 150
             }
151
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
151
+            $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
152 152
             $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
153 153
         }
154 154
 
155
-		$sql.= $db->order($sortfield, $sortorder);
156
-
157
-		if ($limit)
158
-		{
159
-			if ($page < 0)
160
-			{
161
-				$page = 0;
162
-			}
163
-			$offset = $limit * $page;
164
-
165
-			$sql.= $db->plimit($limit + 1, $offset);
166
-		}
167
-		$result = $db->query($sql);
168
-		if ($result)
169
-		{
170
-			$num = $db->num_rows($result);
171
-			$min = min($num, ($limit <= 0 ? $num : $limit));
172
-			while ($i < $min)
173
-			{
174
-				$obj = $db->fetch_object($result);
175
-				$contact_static = new Contact($db);
176
-				if ($contact_static->fetch($obj->rowid))
177
-				{
178
-					$obj_ret[] = $this->_cleanObjectDatas($contact_static);
179
-				}
180
-				$i++;
181
-			}
182
-		}
183
-		else {
184
-			throw new RestException(503, 'Error when retrieve contacts : ' . $sql);
185
-		}
186
-		if (!count($obj_ret))
187
-		{
188
-			throw new RestException(404, 'Contacts not found');
189
-		}
190
-		return $obj_ret;
191
-	}
192
-
193
-	/**
194
-	 * Create contact object
195
-	 *
196
-	 * @param   array   $request_data   Request datas
197
-	 * @return  int     ID of contact
198
-	 */
155
+        $sql.= $db->order($sortfield, $sortorder);
156
+
157
+        if ($limit)
158
+        {
159
+            if ($page < 0)
160
+            {
161
+                $page = 0;
162
+            }
163
+            $offset = $limit * $page;
164
+
165
+            $sql.= $db->plimit($limit + 1, $offset);
166
+        }
167
+        $result = $db->query($sql);
168
+        if ($result)
169
+        {
170
+            $num = $db->num_rows($result);
171
+            $min = min($num, ($limit <= 0 ? $num : $limit));
172
+            while ($i < $min)
173
+            {
174
+                $obj = $db->fetch_object($result);
175
+                $contact_static = new Contact($db);
176
+                if ($contact_static->fetch($obj->rowid))
177
+                {
178
+                    $obj_ret[] = $this->_cleanObjectDatas($contact_static);
179
+                }
180
+                $i++;
181
+            }
182
+        }
183
+        else {
184
+            throw new RestException(503, 'Error when retrieve contacts : ' . $sql);
185
+        }
186
+        if (!count($obj_ret))
187
+        {
188
+            throw new RestException(404, 'Contacts not found');
189
+        }
190
+        return $obj_ret;
191
+    }
192
+
193
+    /**
194
+     * Create contact object
195
+     *
196
+     * @param   array   $request_data   Request datas
197
+     * @return  int     ID of contact
198
+     */
199 199
     function post($request_data = null)
200 200
     {
201
-		if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
202
-		{
203
-			throw new RestException(401, 'No permission to create/update contacts');
204
-		}
205
-		// Check mandatory fields
206
-		$result = $this->_validate($request_data);
207
-
208
-		foreach ($request_data as $field => $value)
209
-		{
210
-			$this->contact->$field = $value;
211
-		}
212
-		if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
213
-		    throw new RestException(500, "Error creating contact", array_merge(array($this->contact->error), $this->contact->errors));
214
-		}
215
-		return $this->contact->id;
216
-	}
217
-
218
-	/**
219
-	 * Update contact
220
-	 *
221
-	 * @param int   $id             Id of contact to update
222
-	 * @param array $request_data   Datas
223
-	 * @return int
224
-	 */
201
+        if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
202
+        {
203
+            throw new RestException(401, 'No permission to create/update contacts');
204
+        }
205
+        // Check mandatory fields
206
+        $result = $this->_validate($request_data);
207
+
208
+        foreach ($request_data as $field => $value)
209
+        {
210
+            $this->contact->$field = $value;
211
+        }
212
+        if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
213
+            throw new RestException(500, "Error creating contact", array_merge(array($this->contact->error), $this->contact->errors));
214
+        }
215
+        return $this->contact->id;
216
+    }
217
+
218
+    /**
219
+     * Update contact
220
+     *
221
+     * @param int   $id             Id of contact to update
222
+     * @param array $request_data   Datas
223
+     * @return int
224
+     */
225 225
     function put($id, $request_data = null)
226 226
     {
227
-		if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
228
-		{
229
-			throw new RestException(401, 'No permission to create/update contacts');
230
-		}
231
-
232
-		$result = $this->contact->fetch($id);
233
-		if (!$result)
234
-		{
235
-			throw new RestException(404, 'Contact not found');
236
-		}
237
-
238
-		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
239
-		{
240
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
241
-		}
242
-
243
-		foreach ($request_data as $field => $value)
244
-		{
227
+        if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
228
+        {
229
+            throw new RestException(401, 'No permission to create/update contacts');
230
+        }
231
+
232
+        $result = $this->contact->fetch($id);
233
+        if (!$result)
234
+        {
235
+            throw new RestException(404, 'Contact not found');
236
+        }
237
+
238
+        if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
239
+        {
240
+            throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
241
+        }
242
+
243
+        foreach ($request_data as $field => $value)
244
+        {
245 245
             if ($field == 'id') continue;
246
-		    $this->contact->$field = $value;
247
-		}
246
+            $this->contact->$field = $value;
247
+        }
248 248
 
249
-		if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
250
-			return $this->get($id);
249
+        if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
250
+            return $this->get($id);
251 251
 
252
-		return false;
253
-	}
252
+        return false;
253
+    }
254 254
 
255
-	/**
256
-	 * Delete contact
257
-	 *
258
-	 * @param   int     $id Contact ID
259
-	 * @return  integer
260
-	 */
255
+    /**
256
+     * Delete contact
257
+     *
258
+     * @param   int     $id Contact ID
259
+     * @return  integer
260
+     */
261 261
     function delete($id)
262 262
     {
263
-		if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer)
264
-		{
265
-			throw new RestException(401, 'No permission to delete contacts');
266
-		}
267
-		$result = $this->contact->fetch($id);
268
-		if (!$result)
269
-		{
270
-			throw new RestException(404, 'Contact not found');
271
-		}
272
-
273
-		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
274
-		{
275
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
276
-		}
277
-
278
-		return $this->contact->delete($id);
279
-	}
280
-
281
-	/**
282
-	 * Create an user account object from contact (external user)
283
-	 *
284
-	 * @param   int   	$id   Id of contact
285
-	 * @param   array   $request_data   Request datas
286
-	 * @return  int     ID of user
287
-	 *
288
-	 * @url	POST {id}/createUser
289
-	 */
263
+        if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer)
264
+        {
265
+            throw new RestException(401, 'No permission to delete contacts');
266
+        }
267
+        $result = $this->contact->fetch($id);
268
+        if (!$result)
269
+        {
270
+            throw new RestException(404, 'Contact not found');
271
+        }
272
+
273
+        if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
274
+        {
275
+            throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
276
+        }
277
+
278
+        return $this->contact->delete($id);
279
+    }
280
+
281
+    /**
282
+     * Create an user account object from contact (external user)
283
+     *
284
+     * @param   int   	$id   Id of contact
285
+     * @param   array   $request_data   Request datas
286
+     * @return  int     ID of user
287
+     *
288
+     * @url	POST {id}/createUser
289
+     */
290 290
     function createUser($id, $request_data = null)
291 291
     {
292
-	    //if (!DolibarrApiAccess::$user->rights->user->user->creer) {
293
-	    //throw new RestException(401);
294
-	    //}
295
-
296
-	    if (!isset($request_data["login"]))
297
-	    				throw new RestException(400, "login field missing");
298
-	    if (!isset($request_data["password"]))
299
-	    				throw new RestException(400, "password field missing");
300
-
301
-	    if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
302
-	        throw new RestException(401, 'No permission to read contacts');
303
-	    }
304
-	    if (!DolibarrApiAccess::$user->rights->user->user->creer) {
305
-	        throw new RestException(401, 'No permission to create user');
306
-	    }
307
-
308
-	    $contact = new Contact($this->db);
309
-	    $contact->fetch($id);
310
-	    if ($contact->id <= 0) {
311
-	        throw new RestException(404, 'Contact not found');
312
-	    }
313
-
314
-	    if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) {
315
-	        throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
316
-	    }
317
-
318
-	    // Check mandatory fields
319
-	    $login = $request_data["login"];
320
-	    $password = $request_data["password"];
321
-	    $useraccount = new User($this->db);
322
-	    $result = $useraccount->create_from_contact($contact,$login,$password);
323
-	    if ($result <= 0) {
324
-	        throw new RestException(500, "User not created");
325
-	    }
326
-	    // password parameter not used in create_from_contact
327
-	    $useraccount->setPassword($useraccount,$password);
328
-
329
-	    return $result;
330
-	}
292
+        //if (!DolibarrApiAccess::$user->rights->user->user->creer) {
293
+        //throw new RestException(401);
294
+        //}
295
+
296
+        if (!isset($request_data["login"]))
297
+                        throw new RestException(400, "login field missing");
298
+        if (!isset($request_data["password"]))
299
+                        throw new RestException(400, "password field missing");
300
+
301
+        if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
302
+            throw new RestException(401, 'No permission to read contacts');
303
+        }
304
+        if (!DolibarrApiAccess::$user->rights->user->user->creer) {
305
+            throw new RestException(401, 'No permission to create user');
306
+        }
307
+
308
+        $contact = new Contact($this->db);
309
+        $contact->fetch($id);
310
+        if ($contact->id <= 0) {
311
+            throw new RestException(404, 'Contact not found');
312
+        }
313
+
314
+        if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) {
315
+            throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
316
+        }
317
+
318
+        // Check mandatory fields
319
+        $login = $request_data["login"];
320
+        $password = $request_data["password"];
321
+        $useraccount = new User($this->db);
322
+        $result = $useraccount->create_from_contact($contact,$login,$password);
323
+        if ($result <= 0) {
324
+            throw new RestException(500, "User not created");
325
+        }
326
+        // password parameter not used in create_from_contact
327
+        $useraccount->setPassword($useraccount,$password);
328
+
329
+        return $result;
330
+    }
331 331
 
332 332
     /**
333 333
      * Get categories for a contact
@@ -342,25 +342,25 @@  discard block
 block discarded – undo
342 342
      *
343 343
      * @url GET {id}/categories
344 344
      */
345
-	function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
346
-	{
347
-		if (! DolibarrApiAccess::$user->rights->categorie->lire) {
348
-			throw new RestException(401);
349
-		}
345
+    function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
346
+    {
347
+        if (! DolibarrApiAccess::$user->rights->categorie->lire) {
348
+            throw new RestException(401);
349
+        }
350 350
 
351
-		$categories = new Categorie($this->db);
351
+        $categories = new Categorie($this->db);
352 352
 
353
-		$result = $categories->getListForItem($id, 'contact', $sortfield, $sortorder, $limit, $page);
353
+        $result = $categories->getListForItem($id, 'contact', $sortfield, $sortorder, $limit, $page);
354 354
 
355
-		if (empty($result)) {
356
-			throw new RestException(404, 'No category found');
357
-		}
355
+        if (empty($result)) {
356
+            throw new RestException(404, 'No category found');
357
+        }
358 358
 
359
-		if ($result < 0) {
360
-			throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
361
-		}
359
+        if ($result < 0) {
360
+            throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
361
+        }
362 362
 
363
-		return $result;
363
+        return $result;
364 364
     }
365 365
 
366 366
 
@@ -373,38 +373,38 @@  discard block
 block discarded – undo
373 373
     function _cleanObjectDatas($object)
374 374
     {
375 375
 
376
-    	$object = parent::_cleanObjectDatas($object);
376
+        $object = parent::_cleanObjectDatas($object);
377 377
 
378
-    	unset($object->total_ht);
379
-    	unset($object->total_tva);
380
-    	unset($object->total_localtax1);
381
-    	unset($object->total_localtax2);
382
-    	unset($object->total_ttc);
378
+        unset($object->total_ht);
379
+        unset($object->total_tva);
380
+        unset($object->total_localtax1);
381
+        unset($object->total_localtax2);
382
+        unset($object->total_ttc);
383 383
 
384
-    	unset($object->note);
385
-    	unset($object->lines);
386
-    	unset($object->thirdparty);
384
+        unset($object->note);
385
+        unset($object->lines);
386
+        unset($object->thirdparty);
387 387
 
388
-    	return $object;
388
+        return $object;
389 389
     }
390 390
 
391
-	/**
392
-	 * Validate fields before create or update object
391
+    /**
392
+     * Validate fields before create or update object
393 393
      *
394
-	 * @param   array|null     $data   Data to validate
395
-	 * @return  array
396
-	 * @throws RestException
397
-	 */
394
+     * @param   array|null     $data   Data to validate
395
+     * @return  array
396
+     * @throws RestException
397
+     */
398 398
     function _validate($data)
399 399
     {
400
-		$contact = array();
401
-		foreach (Contacts::$FIELDS as $field)
402
-		{
403
-			if (!isset($data[$field]))
404
-				throw new RestException(400, "$field field missing");
405
-			$contact[$field] = $data[$field];
406
-		}
407
-
408
-		return $contact;
409
-	}
400
+        $contact = array();
401
+        foreach (Contacts::$FIELDS as $field)
402
+        {
403
+            if (!isset($data[$field]))
404
+                throw new RestException(400, "$field field missing");
405
+            $contact[$field] = $data[$field];
406
+        }
407
+
408
+        return $contact;
409
+    }
410 410
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
83 83
 		{
84
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
84
+			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
85 85
 		}
86 86
 
87 87
 		return $this->_cleanObjectDatas($this->contact);
@@ -122,37 +122,37 @@  discard block
 block discarded – undo
122 122
 			$search_sale = DolibarrApiAccess::$user->id;
123 123
 
124 124
 		$sql = "SELECT t.rowid";
125
-		$sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t";
126
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object = t.rowid";
125
+		$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
126
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as te ON te.fk_object = t.rowid";
127 127
 		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
128 128
 			// We need this table joined to the select in order to filter by sale
129
-			$sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
129
+			$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
130 130
 		}
131
-		$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid";
132
-		$sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')';
133
-		if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")";
131
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
132
+		$sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')';
133
+		if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
134 134
 
135 135
 		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
136
-			$sql.= " AND t.fk_soc = sc.fk_soc";
136
+			$sql .= " AND t.fk_soc = sc.fk_soc";
137 137
 		if ($search_sale > 0)
138
-			$sql.= " AND s.rowid = sc.fk_soc";  // Join for the needed table to filter by sale
138
+			$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
139 139
 		// Insert sale filter
140 140
 		if ($search_sale > 0)
141 141
 		{
142
-			$sql .= " AND sc.fk_user = " . $search_sale;
142
+			$sql .= " AND sc.fk_user = ".$search_sale;
143 143
 		}
144 144
 	    // Add sql filters
145 145
         if ($sqlfilters)
146 146
         {
147
-            if (! DolibarrApi::_checkFilters($sqlfilters))
147
+            if (!DolibarrApi::_checkFilters($sqlfilters))
148 148
             {
149 149
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
150 150
             }
151
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
152
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
151
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
152
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
153 153
         }
154 154
 
155
-		$sql.= $db->order($sortfield, $sortorder);
155
+		$sql .= $db->order($sortfield, $sortorder);
156 156
 
157 157
 		if ($limit)
158 158
 		{
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			}
163 163
 			$offset = $limit * $page;
164 164
 
165
-			$sql.= $db->plimit($limit + 1, $offset);
165
+			$sql .= $db->plimit($limit + 1, $offset);
166 166
 		}
167 167
 		$result = $db->query($sql);
168 168
 		if ($result)
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			}
182 182
 		}
183 183
 		else {
184
-			throw new RestException(503, 'Error when retrieve contacts : ' . $sql);
184
+			throw new RestException(503, 'Error when retrieve contacts : '.$sql);
185 185
 		}
186 186
 		if (!count($obj_ret))
187 187
 		{
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
239 239
 		{
240
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
240
+			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
241 241
 		}
242 242
 
243 243
 		foreach ($request_data as $field => $value)
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
 		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
274 274
 		{
275
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
275
+			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
276 276
 		}
277 277
 
278 278
 		return $this->contact->delete($id);
@@ -312,19 +312,19 @@  discard block
 block discarded – undo
312 312
 	    }
313 313
 
314 314
 	    if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) {
315
-	        throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
315
+	        throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
316 316
 	    }
317 317
 
318 318
 	    // Check mandatory fields
319 319
 	    $login = $request_data["login"];
320 320
 	    $password = $request_data["password"];
321 321
 	    $useraccount = new User($this->db);
322
-	    $result = $useraccount->create_from_contact($contact,$login,$password);
322
+	    $result = $useraccount->create_from_contact($contact, $login, $password);
323 323
 	    if ($result <= 0) {
324 324
 	        throw new RestException(500, "User not created");
325 325
 	    }
326 326
 	    // password parameter not used in create_from_contact
327
-	    $useraccount->setPassword($useraccount,$password);
327
+	    $useraccount->setPassword($useraccount, $password);
328 328
 
329 329
 	    return $result;
330 330
 	}
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      */
345 345
 	function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
346 346
 	{
347
-		if (! DolibarrApiAccess::$user->rights->categorie->lire) {
347
+		if (!DolibarrApiAccess::$user->rights->categorie->lire) {
348 348
 			throw new RestException(401);
349 349
 		}
350 350
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -18 removed lines patch added patch discarded remove patch
@@ -118,8 +118,9 @@  discard block
 block discarded – undo
118 118
 
119 119
 		// If the internal user must only see his customers, force searching by him
120 120
 		$search_sale = 0;
121
-		if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)
122
-			$search_sale = DolibarrApiAccess::$user->id;
121
+		if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
122
+					$search_sale = DolibarrApiAccess::$user->id;
123
+		}
123 124
 
124 125
 		$sql = "SELECT t.rowid";
125 126
 		$sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t";
@@ -130,12 +131,17 @@  discard block
 block discarded – undo
130 131
 		}
131 132
 		$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid";
132 133
 		$sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')';
133
-		if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")";
134
+		if ($socids) {
135
+		    $sql.= " AND t.fk_soc IN (" . $socids . ")";
136
+		}
134 137
 
135
-		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
136
-			$sql.= " AND t.fk_soc = sc.fk_soc";
137
-		if ($search_sale > 0)
138
-			$sql.= " AND s.rowid = sc.fk_soc";  // Join for the needed table to filter by sale
138
+		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
139
+					$sql.= " AND t.fk_soc = sc.fk_soc";
140
+		}
141
+		if ($search_sale > 0) {
142
+					$sql.= " AND s.rowid = sc.fk_soc";
143
+		}
144
+		// Join for the needed table to filter by sale
139 145
 		// Insert sale filter
140 146
 		if ($search_sale > 0)
141 147
 		{
@@ -179,8 +185,7 @@  discard block
 block discarded – undo
179 185
 				}
180 186
 				$i++;
181 187
 			}
182
-		}
183
-		else {
188
+		} else {
184 189
 			throw new RestException(503, 'Error when retrieve contacts : ' . $sql);
185 190
 		}
186 191
 		if (!count($obj_ret))
@@ -242,12 +247,15 @@  discard block
 block discarded – undo
242 247
 
243 248
 		foreach ($request_data as $field => $value)
244 249
 		{
245
-            if ($field == 'id') continue;
250
+            if ($field == 'id') {
251
+                continue;
252
+            }
246 253
 		    $this->contact->$field = $value;
247 254
 		}
248 255
 
249
-		if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
250
-			return $this->get($id);
256
+		if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
257
+					return $this->get($id);
258
+		}
251 259
 
252 260
 		return false;
253 261
 	}
@@ -293,10 +301,12 @@  discard block
 block discarded – undo
293 301
 	    //throw new RestException(401);
294 302
 	    //}
295 303
 
296
-	    if (!isset($request_data["login"]))
297
-	    				throw new RestException(400, "login field missing");
298
-	    if (!isset($request_data["password"]))
299
-	    				throw new RestException(400, "password field missing");
304
+	    if (!isset($request_data["login"])) {
305
+	    	    				throw new RestException(400, "login field missing");
306
+	    }
307
+	    if (!isset($request_data["password"])) {
308
+	    	    				throw new RestException(400, "password field missing");
309
+	    }
300 310
 
301 311
 	    if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
302 312
 	        throw new RestException(401, 'No permission to read contacts');
@@ -400,8 +410,9 @@  discard block
 block discarded – undo
400 410
 		$contact = array();
401 411
 		foreach (Contacts::$FIELDS as $field)
402 412
 		{
403
-			if (!isset($data[$field]))
404
-				throw new RestException(400, "$field field missing");
413
+			if (!isset($data[$field])) {
414
+							throw new RestException(400, "$field field missing");
415
+			}
405 416
 			$contact[$field] = $data[$field];
406 417
 		}
407 418
 
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/societeaccount.class.php 3 patches
Indentation   +452 added lines, -452 removed lines patch added patch discarded remove patch
@@ -35,320 +35,320 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class SocieteAccount extends CommonObject
37 37
 {
38
-	/**
39
-	 * @var string ID to identify managed object
40
-	 */
41
-	public $element = 'societeaccount';
42
-
43
-	/**
44
-	 * @var string Name of table without prefix where object is stored
45
-	 */
46
-	public $table_element = 'societe_account';
47
-
48
-	/**
49
-	 * @var array  Does societeaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
50
-	 */
51
-	public $ismultientitymanaged = 0;
52
-
53
-	/**
54
-	 * @var string String with name of icon for societeaccount. Must be the part after the 'object_' into object_myobject.png
55
-	 */
56
-	public $picto = 'lock';
57
-
58
-
59
-	/**
60
-	 *  'type' if the field format.
61
-	 *  'label' the translation key.
62
-	 *  'enabled' is a condition when the field must be managed.
63
-	 *  'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
64
-	 *  'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
65
-	 *  'index' if we want an index in database.
66
-	 *  'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
67
-	 *  'position' is the sort order of field.
68
-	 *  'searchall' is 1 if we want to search in this field when making a search from the quick search button.
69
-	 *  'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
70
-	 *  'help' is a string visible as a tooltip on field
71
-	 *  'comment' is not used. You can store here any text of your choice. It is not used by application.
72
-	 *  'default' is a default value for creation (can still be replaced by the global setup of default values)
73
-	 *  'showoncombobox' if field must be shown into the label of combobox
74
-	 */
75
-
76
-	// BEGIN MODULEBUILDER PROPERTIES
77
-	/**
78
-	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
79
-	 */
80
-	public $fields=array(
81
-		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
82
-		'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'default'=>1),
83
-		'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>-1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Key account',),
84
-		'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10),
85
-		'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>0, 'enabled'=>1, 'position'=>30),
86
-		'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1),
87
-		'pass_temp'    => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,),
88
-		'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1),
89
-		'site' => array('type'=>'varchar(128)', 'label'=>'Site', 'visible'=>-1, 'enabled'=>1, 'position'=>41),
90
-		'fk_website' => array('type'=>'integer:Website:website/class/website.class.php', 'label'=>'WebSite', 'visible'=>1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'index'=>1),
91
-		'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,),
92
-		'date_previous_login' => array('type'=>'datetime', 'label'=>'PreviousConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>51, 'notnull'=>0,),
93
-		//'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,),
94
-		'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,),
95
-		'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
96
-		'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
97
-		'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
98
-		'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
99
-		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
100
-		'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')),
101
-	);
102
-
103
-	/**
104
-	 * @var int ID
105
-	 */
106
-	public $rowid;
107
-
108
-	/**
109
-	 * @var int Entity
110
-	 */
111
-	public $entity;
112
-
113
-	public $key_account;
114
-	public $login;
115
-	public $pass_encoding;
116
-	public $pass_crypted;
117
-	public $pass_temp;
118
-
119
-	/**
120
-	 * @var int Thirdparty ID
121
-	 */
38
+    /**
39
+     * @var string ID to identify managed object
40
+     */
41
+    public $element = 'societeaccount';
42
+
43
+    /**
44
+     * @var string Name of table without prefix where object is stored
45
+     */
46
+    public $table_element = 'societe_account';
47
+
48
+    /**
49
+     * @var array  Does societeaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
50
+     */
51
+    public $ismultientitymanaged = 0;
52
+
53
+    /**
54
+     * @var string String with name of icon for societeaccount. Must be the part after the 'object_' into object_myobject.png
55
+     */
56
+    public $picto = 'lock';
57
+
58
+
59
+    /**
60
+     *  'type' if the field format.
61
+     *  'label' the translation key.
62
+     *  'enabled' is a condition when the field must be managed.
63
+     *  'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
64
+     *  'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
65
+     *  'index' if we want an index in database.
66
+     *  'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
67
+     *  'position' is the sort order of field.
68
+     *  'searchall' is 1 if we want to search in this field when making a search from the quick search button.
69
+     *  'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
70
+     *  'help' is a string visible as a tooltip on field
71
+     *  'comment' is not used. You can store here any text of your choice. It is not used by application.
72
+     *  'default' is a default value for creation (can still be replaced by the global setup of default values)
73
+     *  'showoncombobox' if field must be shown into the label of combobox
74
+     */
75
+
76
+    // BEGIN MODULEBUILDER PROPERTIES
77
+    /**
78
+     * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
79
+     */
80
+    public $fields=array(
81
+        'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
82
+        'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'default'=>1),
83
+        'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>-1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Key account',),
84
+        'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10),
85
+        'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>0, 'enabled'=>1, 'position'=>30),
86
+        'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1),
87
+        'pass_temp'    => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,),
88
+        'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1),
89
+        'site' => array('type'=>'varchar(128)', 'label'=>'Site', 'visible'=>-1, 'enabled'=>1, 'position'=>41),
90
+        'fk_website' => array('type'=>'integer:Website:website/class/website.class.php', 'label'=>'WebSite', 'visible'=>1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'index'=>1),
91
+        'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,),
92
+        'date_previous_login' => array('type'=>'datetime', 'label'=>'PreviousConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>51, 'notnull'=>0,),
93
+        //'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,),
94
+        'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,),
95
+        'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
96
+        'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
97
+        'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
98
+        'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
99
+        'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
100
+        'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')),
101
+    );
102
+
103
+    /**
104
+     * @var int ID
105
+     */
106
+    public $rowid;
107
+
108
+    /**
109
+     * @var int Entity
110
+     */
111
+    public $entity;
112
+
113
+    public $key_account;
114
+    public $login;
115
+    public $pass_encoding;
116
+    public $pass_crypted;
117
+    public $pass_temp;
118
+
119
+    /**
120
+     * @var int Thirdparty ID
121
+     */
122 122
     public $fk_soc;
123 123
 
124
-	public $site;
125
-	public $date_last_login;
126
-	public $date_previous_login;
127
-	public $note_private;
128
-	public $date_creation;
129
-	public $tms;
124
+    public $site;
125
+    public $date_last_login;
126
+    public $date_previous_login;
127
+    public $note_private;
128
+    public $date_creation;
129
+    public $tms;
130 130
 
131
-	/**
131
+    /**
132 132
      * @var int ID
133 133
      */
134
-	public $fk_user_creat;
134
+    public $fk_user_creat;
135 135
 
136
-	/**
136
+    /**
137 137
      * @var int ID
138 138
      */
139
-	public $fk_user_modif;
140
-
141
-	public $import_key;
142
-
143
-	/**
144
-	 * @var int Status
145
-	 */
146
-	public $status;
147
-
148
-	// END MODULEBUILDER PROPERTIES
149
-
150
-
151
-
152
-
153
-	// If this object has a subtable with lines
154
-
155
-	/**
156
-	 * @var int    Name of subtable line
157
-	 */
158
-	//public $table_element_line = 'societe_accountdet';
159
-	/**
160
-	 * @var int    Field with ID of parent key if this field has a parent
161
-	 */
162
-	//public $fk_element = 'fk_societe_account';
163
-	/**
164
-	 * @var int    Name of subtable class that manage subtable lines
165
-	 */
166
-	//public $class_element_line = 'societeAccountline';
167
-	/**
168
-	 * @var array  Array of child tables (child tables to delete before deleting a record)
169
-	 */
170
-	//protected $childtables=array('societe_accountdet');
171
-	/**
172
-	 * @var societeAccountLine[]     Array of subtable lines
173
-	 */
174
-	//public $lines = array();
175
-
176
-
177
-
178
-	/**
179
-	 * Constructor
180
-	 *
181
-	 * @param DoliDb $db Database handler
182
-	 */
183
-	public function __construct(DoliDB $db)
184
-	{
185
-		global $conf;
186
-
187
-		$this->db = $db;
188
-
189
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
190
-	}
191
-
192
-	/**
193
-	 * Create object into database
194
-	 *
195
-	 * @param  User $user      User that creates
196
-	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
197
-	 * @return int             <0 if KO, Id of created object if OK
198
-	 */
199
-	public function create(User $user, $notrigger = false)
200
-	{
201
-		return $this->createCommon($user, $notrigger);
202
-	}
203
-
204
-	/**
205
-	 * Clone and object into another one
206
-	 *
207
-	 * @param  	User 	$user      	User that creates
208
-	 * @param  	int 	$fromid     Id of object to clone
209
-	 * @return 	mixed 				New object created, <0 if KO
210
-	 */
211
-	public function createFromClone(User $user, $fromid)
212
-	{
213
-		global $hookmanager, $langs;
214
-	    $error = 0;
215
-
216
-	    dol_syslog(__METHOD__, LOG_DEBUG);
217
-
218
-	    $object = new self($this->db);
219
-
220
-	    $this->db->begin();
221
-
222
-	    // Load source object
223
-	    $object->fetchCommon($fromid);
224
-	    // Reset some properties
225
-	    unset($object->id);
226
-	    unset($object->fk_user_creat);
227
-	    unset($object->import_key);
228
-
229
-	    // Clear fields
230
-	    $object->ref = "copy_of_".$object->ref;
231
-	    $object->title = $langs->trans("CopyOf")." ".$object->title;
232
-	    // ...
233
-
234
-	    // Create clone
235
-		$object->context['createfromclone'] = 'createfromclone';
236
-	    $result = $object->createCommon($user);
237
-	    if ($result < 0) {
238
-	        $error++;
239
-	        $this->error = $object->error;
240
-	        $this->errors = $object->errors;
241
-	    }
242
-
243
-	    // End
244
-	    if (!$error) {
245
-	        $this->db->commit();
246
-	        return $object;
247
-	    } else {
248
-	        $this->db->rollback();
249
-	        return -1;
250
-	    }
251
-	}
252
-
253
-	/**
254
-	 * Load object in memory from the database
255
-	 *
256
-	 * @param int    $id   Id object
257
-	 * @param string $ref  Ref
258
-	 * @return int         <0 if KO, 0 if not found, >0 if OK
259
-	 */
260
-	public function fetch($id, $ref = null)
261
-	{
262
-		$result = $this->fetchCommon($id, $ref);
263
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
264
-		return $result;
265
-	}
266
-
267
-	/**
268
-	 * Load object lines in memory from the database
269
-	 *
270
-	 * @return int         <0 if KO, 0 if not found, >0 if OK
271
-	 */
272
-	public function fetchLines()
273
-	{
274
-		$this->lines=array();
275
-
276
-		// Load lines with object societeAccountLine
277
-
278
-		return count($this->lines)?1:0;
279
-	}
280
-
281
-	/**
282
-	 * Try to find the external customer id of a thirdparty for an another site/system.
283
-	 *
284
-	 * @param	int		$id			Id of third party
285
-	 * @param	string	$site		Site (example: 'stripe', '...')
286
-	 * @param	int		$status		Status (0=test, 1=live)
287
-	 * @return	string				Stripe customer ref 'cu_xxxxxxxxxxxxx' or ''
288
-	 */
289
-	public function getCustomerAccount($id, $site, $status=0)
290
-	{
291
-		$sql = "SELECT sa.key_account as key_account, sa.entity";
292
-		$sql.= " FROM " . MAIN_DB_PREFIX . "societe_account as sa";
293
-		$sql.= " WHERE sa.fk_soc = " . $id;
294
-		$sql.= " AND sa.entity IN (".getEntity('societe').")";
295
-		$sql.= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status);
296
-		$sql.= " AND key_account IS NOT NULL AND key_account <> ''";
297
-		//$sql.= " ORDER BY sa.key_account DESC";
298
-
299
-		dol_syslog(get_class($this) . "::getCustomerAccount Try to find the first system customer id for ".$site." of thirdparty id=".$id." (exemple: cus_.... for stripe)", LOG_DEBUG);
300
-		$result = $this->db->query($sql);
301
-		if ($result) {
302
-			if ($this->db->num_rows($result)) {
303
-				$obj = $this->db->fetch_object($result);
304
-				$key = $obj->key_account;
305
-			} else {
306
-				$key = '';
307
-			}
308
-		} else {
309
-			$key = '';
310
-		}
311
-
312
-		return $key;
313
-	}
314
-
315
-	/**
316
-	 * Update object into database
317
-	 *
318
-	 * @param  User $user      User that modifies
319
-	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
320
-	 * @return int             <0 if KO, >0 if OK
321
-	 */
322
-	public function update(User $user, $notrigger = false)
323
-	{
324
-		return $this->updateCommon($user, $notrigger);
325
-	}
326
-
327
-	/**
328
-	 * Delete object in database
329
-	 *
330
-	 * @param User $user       User that deletes
331
-	 * @param bool $notrigger  false=launch triggers after, true=disable triggers
332
-	 * @return int             <0 if KO, >0 if OK
333
-	 */
334
-	public function delete(User $user, $notrigger = false)
335
-	{
336
-		return $this->deleteCommon($user, $notrigger);
337
-	}
338
-
339
-	/**
340
-	 *  Return a link to the object card (with optionaly the picto)
341
-	 *
342
-	 *	@param	int		$withpicto					Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
343
-	 *	@param	string	$option						On what the link point to ('nolink', ...)
139
+    public $fk_user_modif;
140
+
141
+    public $import_key;
142
+
143
+    /**
144
+     * @var int Status
145
+     */
146
+    public $status;
147
+
148
+    // END MODULEBUILDER PROPERTIES
149
+
150
+
151
+
152
+
153
+    // If this object has a subtable with lines
154
+
155
+    /**
156
+     * @var int    Name of subtable line
157
+     */
158
+    //public $table_element_line = 'societe_accountdet';
159
+    /**
160
+     * @var int    Field with ID of parent key if this field has a parent
161
+     */
162
+    //public $fk_element = 'fk_societe_account';
163
+    /**
164
+     * @var int    Name of subtable class that manage subtable lines
165
+     */
166
+    //public $class_element_line = 'societeAccountline';
167
+    /**
168
+     * @var array  Array of child tables (child tables to delete before deleting a record)
169
+     */
170
+    //protected $childtables=array('societe_accountdet');
171
+    /**
172
+     * @var societeAccountLine[]     Array of subtable lines
173
+     */
174
+    //public $lines = array();
175
+
176
+
177
+
178
+    /**
179
+     * Constructor
180
+     *
181
+     * @param DoliDb $db Database handler
182
+     */
183
+    public function __construct(DoliDB $db)
184
+    {
185
+        global $conf;
186
+
187
+        $this->db = $db;
188
+
189
+        if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
190
+    }
191
+
192
+    /**
193
+     * Create object into database
194
+     *
195
+     * @param  User $user      User that creates
196
+     * @param  bool $notrigger false=launch triggers after, true=disable triggers
197
+     * @return int             <0 if KO, Id of created object if OK
198
+     */
199
+    public function create(User $user, $notrigger = false)
200
+    {
201
+        return $this->createCommon($user, $notrigger);
202
+    }
203
+
204
+    /**
205
+     * Clone and object into another one
206
+     *
207
+     * @param  	User 	$user      	User that creates
208
+     * @param  	int 	$fromid     Id of object to clone
209
+     * @return 	mixed 				New object created, <0 if KO
210
+     */
211
+    public function createFromClone(User $user, $fromid)
212
+    {
213
+        global $hookmanager, $langs;
214
+        $error = 0;
215
+
216
+        dol_syslog(__METHOD__, LOG_DEBUG);
217
+
218
+        $object = new self($this->db);
219
+
220
+        $this->db->begin();
221
+
222
+        // Load source object
223
+        $object->fetchCommon($fromid);
224
+        // Reset some properties
225
+        unset($object->id);
226
+        unset($object->fk_user_creat);
227
+        unset($object->import_key);
228
+
229
+        // Clear fields
230
+        $object->ref = "copy_of_".$object->ref;
231
+        $object->title = $langs->trans("CopyOf")." ".$object->title;
232
+        // ...
233
+
234
+        // Create clone
235
+        $object->context['createfromclone'] = 'createfromclone';
236
+        $result = $object->createCommon($user);
237
+        if ($result < 0) {
238
+            $error++;
239
+            $this->error = $object->error;
240
+            $this->errors = $object->errors;
241
+        }
242
+
243
+        // End
244
+        if (!$error) {
245
+            $this->db->commit();
246
+            return $object;
247
+        } else {
248
+            $this->db->rollback();
249
+            return -1;
250
+        }
251
+    }
252
+
253
+    /**
254
+     * Load object in memory from the database
255
+     *
256
+     * @param int    $id   Id object
257
+     * @param string $ref  Ref
258
+     * @return int         <0 if KO, 0 if not found, >0 if OK
259
+     */
260
+    public function fetch($id, $ref = null)
261
+    {
262
+        $result = $this->fetchCommon($id, $ref);
263
+        if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
264
+        return $result;
265
+    }
266
+
267
+    /**
268
+     * Load object lines in memory from the database
269
+     *
270
+     * @return int         <0 if KO, 0 if not found, >0 if OK
271
+     */
272
+    public function fetchLines()
273
+    {
274
+        $this->lines=array();
275
+
276
+        // Load lines with object societeAccountLine
277
+
278
+        return count($this->lines)?1:0;
279
+    }
280
+
281
+    /**
282
+     * Try to find the external customer id of a thirdparty for an another site/system.
283
+     *
284
+     * @param	int		$id			Id of third party
285
+     * @param	string	$site		Site (example: 'stripe', '...')
286
+     * @param	int		$status		Status (0=test, 1=live)
287
+     * @return	string				Stripe customer ref 'cu_xxxxxxxxxxxxx' or ''
288
+     */
289
+    public function getCustomerAccount($id, $site, $status=0)
290
+    {
291
+        $sql = "SELECT sa.key_account as key_account, sa.entity";
292
+        $sql.= " FROM " . MAIN_DB_PREFIX . "societe_account as sa";
293
+        $sql.= " WHERE sa.fk_soc = " . $id;
294
+        $sql.= " AND sa.entity IN (".getEntity('societe').")";
295
+        $sql.= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status);
296
+        $sql.= " AND key_account IS NOT NULL AND key_account <> ''";
297
+        //$sql.= " ORDER BY sa.key_account DESC";
298
+
299
+        dol_syslog(get_class($this) . "::getCustomerAccount Try to find the first system customer id for ".$site." of thirdparty id=".$id." (exemple: cus_.... for stripe)", LOG_DEBUG);
300
+        $result = $this->db->query($sql);
301
+        if ($result) {
302
+            if ($this->db->num_rows($result)) {
303
+                $obj = $this->db->fetch_object($result);
304
+                $key = $obj->key_account;
305
+            } else {
306
+                $key = '';
307
+            }
308
+        } else {
309
+            $key = '';
310
+        }
311
+
312
+        return $key;
313
+    }
314
+
315
+    /**
316
+     * Update object into database
317
+     *
318
+     * @param  User $user      User that modifies
319
+     * @param  bool $notrigger false=launch triggers after, true=disable triggers
320
+     * @return int             <0 if KO, >0 if OK
321
+     */
322
+    public function update(User $user, $notrigger = false)
323
+    {
324
+        return $this->updateCommon($user, $notrigger);
325
+    }
326
+
327
+    /**
328
+     * Delete object in database
329
+     *
330
+     * @param User $user       User that deletes
331
+     * @param bool $notrigger  false=launch triggers after, true=disable triggers
332
+     * @return int             <0 if KO, >0 if OK
333
+     */
334
+    public function delete(User $user, $notrigger = false)
335
+    {
336
+        return $this->deleteCommon($user, $notrigger);
337
+    }
338
+
339
+    /**
340
+     *  Return a link to the object card (with optionaly the picto)
341
+     *
342
+     *	@param	int		$withpicto					Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
343
+     *	@param	string	$option						On what the link point to ('nolink', ...)
344 344
      *  @param	int  	$notooltip					1=Disable tooltip
345 345
      *  @param  string  $morecss            		Add more css on link
346 346
      *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
347
-	 *	@return	string								String with URL
348
-	 */
349
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
350
-	{
351
-		global $db, $conf, $langs;
347
+     *	@return	string								String with URL
348
+     */
349
+    function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
350
+    {
351
+        global $db, $conf, $langs;
352 352
         global $dolibarr_main_authentication, $dolibarr_main_demo;
353 353
         global $menumanager;
354 354
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 
369 369
         if ($option != 'nolink')
370 370
         {
371
-	        // Add param to save lastsearch_values or not
372
-	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
373
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
374
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
371
+            // Add param to save lastsearch_values or not
372
+            $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
373
+            if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
374
+            if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
375 375
         }
376 376
 
377 377
         $linkclose='';
@@ -387,152 +387,152 @@  discard block
 block discarded – undo
387 387
         }
388 388
         else $linkclose = ($morecss?' class="'.$morecss.'"':'');
389 389
 
390
-		$linkstart = '<a href="'.$url.'"';
391
-		$linkstart.=$linkclose.'>';
392
-		$linkend='</a>';
393
-
394
-		$result .= $linkstart;
395
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
396
-		if ($withpicto != 2) $result.= $this->ref;
397
-		$result .= $linkend;
398
-
399
-		return $result;
400
-	}
401
-
402
-	/**
403
-	 * Return link to download file from a direct external access
404
-	 *
405
-	 * @param	int				$withpicto			Add download picto into link
406
-	 * @return	string			HTML link to file
407
-	 */
408
-	function getDirectExternalLink($withpicto=0)
409
-	{
410
-		return 'todo';
411
-	}
412
-
413
-	/**
414
-	 *  Retourne le libelle du status d'un user (actif, inactif)
415
-	 *
416
-	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
417
-	 *  @return	string 			       Label of status
418
-	 */
419
-	function getLibStatut($mode=0)
420
-	{
421
-		return $this->LibStatut($this->status,$mode);
422
-	}
390
+        $linkstart = '<a href="'.$url.'"';
391
+        $linkstart.=$linkclose.'>';
392
+        $linkend='</a>';
393
+
394
+        $result .= $linkstart;
395
+        if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
396
+        if ($withpicto != 2) $result.= $this->ref;
397
+        $result .= $linkend;
398
+
399
+        return $result;
400
+    }
401
+
402
+    /**
403
+     * Return link to download file from a direct external access
404
+     *
405
+     * @param	int				$withpicto			Add download picto into link
406
+     * @return	string			HTML link to file
407
+     */
408
+    function getDirectExternalLink($withpicto=0)
409
+    {
410
+        return 'todo';
411
+    }
412
+
413
+    /**
414
+     *  Retourne le libelle du status d'un user (actif, inactif)
415
+     *
416
+     *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
417
+     *  @return	string 			       Label of status
418
+     */
419
+    function getLibStatut($mode=0)
420
+    {
421
+        return $this->LibStatut($this->status,$mode);
422
+    }
423 423
 
424 424
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
425
-	/**
426
-	 *  Return the status
427
-	 *
428
-	 *  @param	int		$status        	Id status
429
-	 *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
430
-	 *  @return string 			       	Label of status
431
-	 */
432
-	static function LibStatut($status,$mode=0)
433
-	{
425
+    /**
426
+     *  Return the status
427
+     *
428
+     *  @param	int		$status        	Id status
429
+     *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
430
+     *  @return string 			       	Label of status
431
+     */
432
+    static function LibStatut($status,$mode=0)
433
+    {
434 434
         // phpcs:enable
435
-		global $langs;
436
-
437
-		if ($mode == 0)
438
-		{
439
-			$prefix='';
440
-			if ($status == 1) return $langs->trans('Enabled');
441
-			elseif ($status == 0) return $langs->trans('Disabled');
442
-		}
443
-		elseif ($mode == 1)
444
-		{
445
-			if ($status == 1) return $langs->trans('Enabled');
446
-			elseif ($status == 0) return $langs->trans('Disabled');
447
-		}
448
-		elseif ($mode == 2)
449
-		{
450
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
451
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
452
-		}
453
-		elseif ($mode == 3)
454
-		{
455
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
456
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
457
-		}
458
-		elseif ($mode == 4)
459
-		{
460
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
461
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
462
-		}
463
-		elseif ($mode == 5)
464
-		{
465
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
466
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
467
-		}
468
-		elseif ($mode == 6)
469
-		{
470
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
471
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
472
-		}
473
-	}
474
-
475
-	/**
476
-	 *	Charge les informations d'ordre info dans l'objet commande
477
-	 *
478
-	 *	@param  int		$id       Id of order
479
-	 *	@return	void
480
-	 */
481
-	function info($id)
482
-	{
483
-		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
484
-		$sql.= ' fk_user_creat, fk_user_modif';
485
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
486
-		$sql.= ' WHERE t.rowid = '.$id;
487
-		$result=$this->db->query($sql);
488
-		if ($result)
489
-		{
490
-			if ($this->db->num_rows($result))
491
-			{
492
-				$obj = $this->db->fetch_object($result);
493
-				$this->id = $obj->rowid;
494
-				if ($obj->fk_user_author)
495
-				{
496
-					$cuser = new User($this->db);
497
-					$cuser->fetch($obj->fk_user_author);
498
-					$this->user_creation   = $cuser;
499
-				}
500
-
501
-				if ($obj->fk_user_valid)
502
-				{
503
-					$vuser = new User($this->db);
504
-					$vuser->fetch($obj->fk_user_valid);
505
-					$this->user_validation = $vuser;
506
-				}
507
-
508
-				if ($obj->fk_user_cloture)
509
-				{
510
-					$cluser = new User($this->db);
511
-					$cluser->fetch($obj->fk_user_cloture);
512
-					$this->user_cloture   = $cluser;
513
-				}
514
-
515
-				$this->date_creation     = $this->db->jdate($obj->datec);
516
-				$this->date_modification = $this->db->jdate($obj->datem);
517
-				$this->date_validation   = $this->db->jdate($obj->datev);
518
-			}
519
-
520
-			$this->db->free($result);
521
-		}
522
-		else
523
-		{
524
-			dol_print_error($this->db);
525
-		}
526
-	}
527
-
528
-	/**
529
-	 * Initialise object with example values
530
-	 * Id must be 0 if object instance is a specimen
531
-	 *
532
-	 * @return void
533
-	 */
534
-	public function initAsSpecimen()
535
-	{
536
-		$this->initAsSpecimenCommon();
537
-	}
435
+        global $langs;
436
+
437
+        if ($mode == 0)
438
+        {
439
+            $prefix='';
440
+            if ($status == 1) return $langs->trans('Enabled');
441
+            elseif ($status == 0) return $langs->trans('Disabled');
442
+        }
443
+        elseif ($mode == 1)
444
+        {
445
+            if ($status == 1) return $langs->trans('Enabled');
446
+            elseif ($status == 0) return $langs->trans('Disabled');
447
+        }
448
+        elseif ($mode == 2)
449
+        {
450
+            if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
451
+            elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
452
+        }
453
+        elseif ($mode == 3)
454
+        {
455
+            if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
456
+            elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
457
+        }
458
+        elseif ($mode == 4)
459
+        {
460
+            if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
461
+            elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
462
+        }
463
+        elseif ($mode == 5)
464
+        {
465
+            if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
466
+            elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
467
+        }
468
+        elseif ($mode == 6)
469
+        {
470
+            if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
471
+            elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
472
+        }
473
+    }
474
+
475
+    /**
476
+     *	Charge les informations d'ordre info dans l'objet commande
477
+     *
478
+     *	@param  int		$id       Id of order
479
+     *	@return	void
480
+     */
481
+    function info($id)
482
+    {
483
+        $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
484
+        $sql.= ' fk_user_creat, fk_user_modif';
485
+        $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
486
+        $sql.= ' WHERE t.rowid = '.$id;
487
+        $result=$this->db->query($sql);
488
+        if ($result)
489
+        {
490
+            if ($this->db->num_rows($result))
491
+            {
492
+                $obj = $this->db->fetch_object($result);
493
+                $this->id = $obj->rowid;
494
+                if ($obj->fk_user_author)
495
+                {
496
+                    $cuser = new User($this->db);
497
+                    $cuser->fetch($obj->fk_user_author);
498
+                    $this->user_creation   = $cuser;
499
+                }
500
+
501
+                if ($obj->fk_user_valid)
502
+                {
503
+                    $vuser = new User($this->db);
504
+                    $vuser->fetch($obj->fk_user_valid);
505
+                    $this->user_validation = $vuser;
506
+                }
507
+
508
+                if ($obj->fk_user_cloture)
509
+                {
510
+                    $cluser = new User($this->db);
511
+                    $cluser->fetch($obj->fk_user_cloture);
512
+                    $this->user_cloture   = $cluser;
513
+                }
514
+
515
+                $this->date_creation     = $this->db->jdate($obj->datec);
516
+                $this->date_modification = $this->db->jdate($obj->datem);
517
+                $this->date_validation   = $this->db->jdate($obj->datev);
518
+            }
519
+
520
+            $this->db->free($result);
521
+        }
522
+        else
523
+        {
524
+            dol_print_error($this->db);
525
+        }
526
+    }
527
+
528
+    /**
529
+     * Initialise object with example values
530
+     * Id must be 0 if object instance is a specimen
531
+     *
532
+     * @return void
533
+     */
534
+    public function initAsSpecimen()
535
+    {
536
+        $this->initAsSpecimenCommon();
537
+    }
538 538
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 
28 28
 // Put here all includes required by your class file
29
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
29
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30 30
 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
31 31
 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
32 32
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	/**
78 78
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
79 79
 	 */
80
-	public $fields=array(
80
+	public $fields = array(
81 81
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
82 82
 		'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'default'=>1),
83 83
 		'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>-1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Key account',),
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
98 98
 		'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
99 99
 		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
100
-		'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')),
100
+		'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active', '0'=>'Disabled')),
101 101
 	);
102 102
 
103 103
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 		$this->db = $db;
188 188
 
189
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
189
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
190 190
 	}
191 191
 
192 192
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	public function fetch($id, $ref = null)
261 261
 	{
262 262
 		$result = $this->fetchCommon($id, $ref);
263
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
263
+		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
264 264
 		return $result;
265 265
 	}
266 266
 
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public function fetchLines()
273 273
 	{
274
-		$this->lines=array();
274
+		$this->lines = array();
275 275
 
276 276
 		// Load lines with object societeAccountLine
277 277
 
278
-		return count($this->lines)?1:0;
278
+		return count($this->lines) ? 1 : 0;
279 279
 	}
280 280
 
281 281
 	/**
@@ -286,17 +286,17 @@  discard block
 block discarded – undo
286 286
 	 * @param	int		$status		Status (0=test, 1=live)
287 287
 	 * @return	string				Stripe customer ref 'cu_xxxxxxxxxxxxx' or ''
288 288
 	 */
289
-	public function getCustomerAccount($id, $site, $status=0)
289
+	public function getCustomerAccount($id, $site, $status = 0)
290 290
 	{
291 291
 		$sql = "SELECT sa.key_account as key_account, sa.entity";
292
-		$sql.= " FROM " . MAIN_DB_PREFIX . "societe_account as sa";
293
-		$sql.= " WHERE sa.fk_soc = " . $id;
294
-		$sql.= " AND sa.entity IN (".getEntity('societe').")";
295
-		$sql.= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status);
296
-		$sql.= " AND key_account IS NOT NULL AND key_account <> ''";
292
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa";
293
+		$sql .= " WHERE sa.fk_soc = ".$id;
294
+		$sql .= " AND sa.entity IN (".getEntity('societe').")";
295
+		$sql .= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status);
296
+		$sql .= " AND key_account IS NOT NULL AND key_account <> ''";
297 297
 		//$sql.= " ORDER BY sa.key_account DESC";
298 298
 
299
-		dol_syslog(get_class($this) . "::getCustomerAccount Try to find the first system customer id for ".$site." of thirdparty id=".$id." (exemple: cus_.... for stripe)", LOG_DEBUG);
299
+		dol_syslog(get_class($this)."::getCustomerAccount Try to find the first system customer id for ".$site." of thirdparty id=".$id." (exemple: cus_.... for stripe)", LOG_DEBUG);
300 300
 		$result = $this->db->query($sql);
301 301
 		if ($result) {
302 302
 			if ($this->db->num_rows($result)) {
@@ -346,54 +346,54 @@  discard block
 block discarded – undo
346 346
      *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
347 347
 	 *	@return	string								String with URL
348 348
 	 */
349
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
349
+	function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
350 350
 	{
351 351
 		global $db, $conf, $langs;
352 352
         global $dolibarr_main_authentication, $dolibarr_main_demo;
353 353
         global $menumanager;
354 354
 
355
-        if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
355
+        if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
356 356
 
357 357
         $result = '';
358 358
         $companylink = '';
359 359
 
360 360
         $this->ref = $this->login;
361 361
 
362
-        $label = '<u>' . $langs->trans("SocieteAccount") . '</u>';
363
-        $label.= '<br>';
364
-        $label.= '<b>' . $langs->trans('Login') . ':</b> ' . $this->ref;
362
+        $label = '<u>'.$langs->trans("SocieteAccount").'</u>';
363
+        $label .= '<br>';
364
+        $label .= '<b>'.$langs->trans('Login').':</b> '.$this->ref;
365 365
         //$label.= '<b>' . $langs->trans('WebSite') . ':</b> ' . $this->ref;
366 366
 
367
-        $url = dol_buildpath('/website/websiteaccount_card.php',1).'?id='.$this->id;
367
+        $url = dol_buildpath('/website/websiteaccount_card.php', 1).'?id='.$this->id;
368 368
 
369 369
         if ($option != 'nolink')
370 370
         {
371 371
 	        // Add param to save lastsearch_values or not
372
-	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
373
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
374
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
372
+	        $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
373
+	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
374
+	        if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
375 375
         }
376 376
 
377
-        $linkclose='';
377
+        $linkclose = '';
378 378
         if (empty($notooltip))
379 379
         {
380
-            if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
380
+            if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
381 381
             {
382
-                $label=$langs->trans("ShowsocieteAccount");
383
-                $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
382
+                $label = $langs->trans("ShowsocieteAccount");
383
+                $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
384 384
             }
385
-            $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
386
-            $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
385
+            $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
386
+            $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
387 387
         }
388
-        else $linkclose = ($morecss?' class="'.$morecss.'"':'');
388
+        else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
389 389
 
390 390
 		$linkstart = '<a href="'.$url.'"';
391
-		$linkstart.=$linkclose.'>';
392
-		$linkend='</a>';
391
+		$linkstart .= $linkclose.'>';
392
+		$linkend = '</a>';
393 393
 
394 394
 		$result .= $linkstart;
395
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
396
-		if ($withpicto != 2) $result.= $this->ref;
395
+		if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
396
+		if ($withpicto != 2) $result .= $this->ref;
397 397
 		$result .= $linkend;
398 398
 
399 399
 		return $result;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @param	int				$withpicto			Add download picto into link
406 406
 	 * @return	string			HTML link to file
407 407
 	 */
408
-	function getDirectExternalLink($withpicto=0)
408
+	function getDirectExternalLink($withpicto = 0)
409 409
 	{
410 410
 		return 'todo';
411 411
 	}
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
417 417
 	 *  @return	string 			       Label of status
418 418
 	 */
419
-	function getLibStatut($mode=0)
419
+	function getLibStatut($mode = 0)
420 420
 	{
421
-		return $this->LibStatut($this->status,$mode);
421
+		return $this->LibStatut($this->status, $mode);
422 422
 	}
423 423
 
424 424
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
 	 *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
430 430
 	 *  @return string 			       	Label of status
431 431
 	 */
432
-	static function LibStatut($status,$mode=0)
432
+	static function LibStatut($status, $mode = 0)
433 433
 	{
434 434
         // phpcs:enable
435 435
 		global $langs;
436 436
 
437 437
 		if ($mode == 0)
438 438
 		{
439
-			$prefix='';
439
+			$prefix = '';
440 440
 			if ($status == 1) return $langs->trans('Enabled');
441 441
 			elseif ($status == 0) return $langs->trans('Disabled');
442 442
 		}
@@ -447,28 +447,28 @@  discard block
 block discarded – undo
447 447
 		}
448 448
 		elseif ($mode == 2)
449 449
 		{
450
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
451
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
450
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
451
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
452 452
 		}
453 453
 		elseif ($mode == 3)
454 454
 		{
455
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
456
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
455
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
456
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
457 457
 		}
458 458
 		elseif ($mode == 4)
459 459
 		{
460
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
461
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
460
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
461
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
462 462
 		}
463 463
 		elseif ($mode == 5)
464 464
 		{
465
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
466
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
465
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
466
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
467 467
 		}
468 468
 		elseif ($mode == 6)
469 469
 		{
470
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
471
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
470
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
471
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
472 472
 		}
473 473
 	}
474 474
 
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	function info($id)
482 482
 	{
483 483
 		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
484
-		$sql.= ' fk_user_creat, fk_user_modif';
485
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
486
-		$sql.= ' WHERE t.rowid = '.$id;
487
-		$result=$this->db->query($sql);
484
+		$sql .= ' fk_user_creat, fk_user_modif';
485
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
486
+		$sql .= ' WHERE t.rowid = '.$id;
487
+		$result = $this->db->query($sql);
488 488
 		if ($result)
489 489
 		{
490 490
 			if ($this->db->num_rows($result))
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 				{
496 496
 					$cuser = new User($this->db);
497 497
 					$cuser->fetch($obj->fk_user_author);
498
-					$this->user_creation   = $cuser;
498
+					$this->user_creation = $cuser;
499 499
 				}
500 500
 
501 501
 				if ($obj->fk_user_valid)
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 				{
510 510
 					$cluser = new User($this->db);
511 511
 					$cluser->fetch($obj->fk_user_cloture);
512
-					$this->user_cloture   = $cluser;
512
+					$this->user_cloture = $cluser;
513 513
 				}
514 514
 
515 515
 				$this->date_creation     = $this->db->jdate($obj->datec);
Please login to merge, or discard this patch.
Braces   +66 added lines, -36 removed lines patch added patch discarded remove patch
@@ -186,7 +186,9 @@  discard block
 block discarded – undo
186 186
 
187 187
 		$this->db = $db;
188 188
 
189
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
189
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
190
+		    $this->fields['rowid']['visible']=0;
191
+		}
190 192
 	}
191 193
 
192 194
 	/**
@@ -260,7 +262,9 @@  discard block
 block discarded – undo
260 262
 	public function fetch($id, $ref = null)
261 263
 	{
262 264
 		$result = $this->fetchCommon($id, $ref);
263
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
265
+		if ($result > 0 && ! empty($this->table_element_line)) {
266
+		    $this->fetchLines();
267
+		}
264 268
 		return $result;
265 269
 	}
266 270
 
@@ -352,7 +356,10 @@  discard block
 block discarded – undo
352 356
         global $dolibarr_main_authentication, $dolibarr_main_demo;
353 357
         global $menumanager;
354 358
 
355
-        if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
359
+        if (! empty($conf->dol_no_mouse_hover)) {
360
+            $notooltip=1;
361
+        }
362
+        // Force disable tooltips
356 363
 
357 364
         $result = '';
358 365
         $companylink = '';
@@ -370,8 +377,12 @@  discard block
 block discarded – undo
370 377
         {
371 378
 	        // Add param to save lastsearch_values or not
372 379
 	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
373
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
374
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
380
+	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) {
381
+	            $add_save_lastsearch_values=1;
382
+	        }
383
+	        if ($add_save_lastsearch_values) {
384
+	            $url.='&save_lastsearch_values=1';
385
+	        }
375 386
         }
376 387
 
377 388
         $linkclose='';
@@ -384,16 +395,21 @@  discard block
 block discarded – undo
384 395
             }
385 396
             $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
386 397
             $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
398
+        } else {
399
+            $linkclose = ($morecss?' class="'.$morecss.'"':'');
387 400
         }
388
-        else $linkclose = ($morecss?' class="'.$morecss.'"':'');
389 401
 
390 402
 		$linkstart = '<a href="'.$url.'"';
391 403
 		$linkstart.=$linkclose.'>';
392 404
 		$linkend='</a>';
393 405
 
394 406
 		$result .= $linkstart;
395
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
396
-		if ($withpicto != 2) $result.= $this->ref;
407
+		if ($withpicto) {
408
+		    $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
409
+		}
410
+		if ($withpicto != 2) {
411
+		    $result.= $this->ref;
412
+		}
397 413
 		$result .= $linkend;
398 414
 
399 415
 		return $result;
@@ -437,38 +453,53 @@  discard block
 block discarded – undo
437 453
 		if ($mode == 0)
438 454
 		{
439 455
 			$prefix='';
440
-			if ($status == 1) return $langs->trans('Enabled');
441
-			elseif ($status == 0) return $langs->trans('Disabled');
442
-		}
443
-		elseif ($mode == 1)
456
+			if ($status == 1) {
457
+			    return $langs->trans('Enabled');
458
+			} elseif ($status == 0) {
459
+			    return $langs->trans('Disabled');
460
+			}
461
+		} elseif ($mode == 1)
444 462
 		{
445
-			if ($status == 1) return $langs->trans('Enabled');
446
-			elseif ($status == 0) return $langs->trans('Disabled');
447
-		}
448
-		elseif ($mode == 2)
463
+			if ($status == 1) {
464
+			    return $langs->trans('Enabled');
465
+			} elseif ($status == 0) {
466
+			    return $langs->trans('Disabled');
467
+			}
468
+		} elseif ($mode == 2)
449 469
 		{
450
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
451
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
452
-		}
453
-		elseif ($mode == 3)
470
+			if ($status == 1) {
471
+			    return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
472
+			} elseif ($status == 0) {
473
+			    return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
474
+			}
475
+		} elseif ($mode == 3)
454 476
 		{
455
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
456
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
457
-		}
458
-		elseif ($mode == 4)
477
+			if ($status == 1) {
478
+			    return img_picto($langs->trans('Enabled'),'statut4');
479
+			} elseif ($status == 0) {
480
+			    return img_picto($langs->trans('Disabled'),'statut5');
481
+			}
482
+		} elseif ($mode == 4)
459 483
 		{
460
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
461
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
462
-		}
463
-		elseif ($mode == 5)
484
+			if ($status == 1) {
485
+			    return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
486
+			} elseif ($status == 0) {
487
+			    return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
488
+			}
489
+		} elseif ($mode == 5)
464 490
 		{
465
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
466
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
467
-		}
468
-		elseif ($mode == 6)
491
+			if ($status == 1) {
492
+			    return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
493
+			} elseif ($status == 0) {
494
+			    return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
495
+			}
496
+		} elseif ($mode == 6)
469 497
 		{
470
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
471
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
498
+			if ($status == 1) {
499
+			    return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
500
+			} elseif ($status == 0) {
501
+			    return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
502
+			}
472 503
 		}
473 504
 	}
474 505
 
@@ -518,8 +549,7 @@  discard block
 block discarded – undo
518 549
 			}
519 550
 
520 551
 			$this->db->free($result);
521
-		}
522
-		else
552
+		} else
523 553
 		{
524 554
 			dol_print_error($this->db);
525 555
 		}
Please login to merge, or discard this patch.