Passed
Branch develop (92bdcd)
by Laurent
32:39
created
htdocs/core/modules/expedition/mod_expedition_safor.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 class mod_expedition_safor extends ModelNumRefExpedition
30 30
 {
31 31
 	/**
32
-     * Dolibarr version of the loaded document
33
-     * @var string
34
-     */
32
+	 * Dolibarr version of the loaded document
33
+	 * @var string
34
+	 */
35 35
 	public $version = 'dolibarr';
36 36
 
37 37
 	public $prefix = 'SH';
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 *	@return     string      text description
61 61
 	 */
62
-    public function info()
63
-    {
64
-    	global $langs;
65
-      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
66
-    }
62
+	public function info()
63
+	{
64
+		global $langs;
65
+	  	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
66
+	}
67 67
 
68 68
 
69 69
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 *	@return     string      Example
73 73
 	 */
74
-    public function getExample()
74
+	public function getExample()
75 75
 	{
76 76
 		return $this->prefix."0501-0001";
77 77
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 *	@return     boolean     false if conflit, true if ok
84 84
 	 */
85
-    public function canBeActivated()
85
+	public function canBeActivated()
86 86
 	{
87 87
 		global $conf, $langs, $db;
88 88
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 *	@param	Object		$shipment	Shipment object
118 118
 	 *	@return string      			Value if OK, 0 if KO
119 119
 	 */
120
-    public function getNextValue($objsoc, $shipment)
120
+	public function getNextValue($objsoc, $shipment)
121 121
 	{
122 122
 		global $db, $conf;
123 123
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		return $this->prefix.$yymm."-".$num;
151 151
 	}
152 152
 
153
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
153
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
154 154
 	/**
155 155
 	 *  Return next free value
156 156
 	 *
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 	 *	@param	Object		$objforref	Shipment object
159 159
 	 *	@return string      			Next free value
160 160
 	 */
161
-    public function expedition_get_num($objsoc, $objforref)
161
+	public function expedition_get_num($objsoc, $objforref)
162 162
 	{
163
-        // phpcs:enable
163
+		// phpcs:enable
164 164
 		return $this->getNextValue($objsoc, $objforref);
165 165
 	}
166 166
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -131,8 +131,11 @@  discard block
 block discarded – undo
131 131
 		if ($resql)
132 132
 		{
133 133
 			$obj = $db->fetch_object($resql);
134
-			if ($obj) $max = intval($obj->max);
135
-			else $max = 0;
134
+			if ($obj) {
135
+				$max = intval($obj->max);
136
+			} else {
137
+				$max = 0;
138
+			}
136 139
 		} else {
137 140
 			dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG);
138 141
 			return -1;
@@ -141,8 +144,13 @@  discard block
 block discarded – undo
141 144
 		$date = time();
142 145
 		$yymm = strftime("%y%m", $date);
143 146
 
144
-		if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
145
-		else $num = sprintf("%04s", $max + 1);
147
+		if ($max >= (pow(10, 4) - 1)) {
148
+			$num = $max + 1;
149
+		}
150
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
151
+		else {
152
+			$num = sprintf("%04s", $max + 1);
153
+		}
146 154
 
147 155
 		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
148 156
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/mod_expedition_ribera.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 class mod_expedition_ribera extends ModelNumRefExpedition
32 32
 {
33 33
 	/**
34
-     * Dolibarr version of the loaded document
35
-     * @var string
36
-     */
34
+	 * Dolibarr version of the loaded document
35
+	 * @var string
36
+	 */
37 37
 	public $version = 'dolibarr';
38 38
 
39 39
 	/**
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 *	@return     string      text description
60 60
 	 */
61
-    public function info()
62
-    {
63
-    	global $conf, $langs, $db;
61
+	public function info()
62
+	{
63
+		global $conf, $langs, $db;
64 64
 
65 65
 		$langs->load("bills");
66 66
 
@@ -87,22 +87,22 @@  discard block
 block discarded – undo
87 87
 		$texte .= '</form>';
88 88
 
89 89
 		return $texte;
90
-    }
90
+	}
91 91
 
92 92
 	/**
93 93
 	 *	Return numbering example
94 94
 	 *
95 95
 	 *	@return     string      Example
96 96
 	 */
97
-    public function getExample()
98
-    {
99
-     	global $conf, $langs, $mysoc;
100
-
101
-    	$old_code_client = $mysoc->code_client;
102
-    	$old_code_type = $mysoc->typent_code;
103
-    	$mysoc->code_client = 'CCCCCCCCCC';
104
-    	$mysoc->typent_code = 'TTTTTTTTTT';
105
-     	$numExample = $this->getNextValue($mysoc, '');
97
+	public function getExample()
98
+	{
99
+	 	global $conf, $langs, $mysoc;
100
+
101
+		$old_code_client = $mysoc->code_client;
102
+		$old_code_type = $mysoc->typent_code;
103
+		$mysoc->code_client = 'CCCCCCCCCC';
104
+		$mysoc->typent_code = 'TTTTTTTTTT';
105
+	 	$numExample = $this->getNextValue($mysoc, '');
106 106
 		$mysoc->code_client = $old_code_client;
107 107
 		$mysoc->typent_code = $old_code_type;
108 108
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			$numExample = $langs->trans('NotConfigured');
112 112
 		}
113 113
 		return $numExample;
114
-    }
114
+	}
115 115
 
116 116
 	/**
117 117
 	 *	Return next value
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 *	@param	Object		$shipment	Shipment object
121 121
 	 *	@return string      			Value if OK, 0 if KO
122 122
 	 */
123
-    public function getNextValue($objsoc, $shipment)
124
-    {
123
+	public function getNextValue($objsoc, $shipment)
124
+	{
125 125
 		global $db, $conf;
126 126
 
127 127
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		return  $numFinal;
142 142
 	}
143 143
 
144
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
144
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
145 145
 	/**
146 146
 	 *  Return next free value
147 147
 	 *
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 	 *	@param	Object		$objforref	Shipment object
150 150
 	 *	@return string      			Next free value
151 151
 	 */
152
-    public function expedition_get_num($objsoc, $objforref)
153
-    {
154
-        // phpcs:enable
155
-        return $this->getNextValue($objsoc, $objforref);
156
-    }
152
+	public function expedition_get_num($objsoc, $objforref)
153
+	{
154
+		// phpcs:enable
155
+		return $this->getNextValue($objsoc, $objforref);
156
+	}
157 157
 }
Please login to merge, or discard this patch.
htdocs/core/modules/expensereport/mod_expensereport_sand.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 class mod_expensereport_sand extends ModeleNumRefExpenseReport
32 32
 {
33 33
 	/**
34
-     * Dolibarr version of the loaded document
35
-     * @var string
36
-     */
34
+	 * Dolibarr version of the loaded document
35
+	 * @var string
36
+	 */
37 37
 	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39 39
 	/**
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	public $name = 'Sand';
55 55
 
56 56
 
57
-    /**
58
-     *  Returns the description of the numbering model
59
-     *
60
-     *  @return     string      Texte descripif
61
-     */
62
-    public function info()
63
-    {
64
-    	global $db, $conf, $langs;
57
+	/**
58
+	 *  Returns the description of the numbering model
59
+	 *
60
+	 *  @return     string      Texte descripif
61
+	 */
62
+	public function info()
63
+	{
64
+		global $db, $conf, $langs;
65 65
 
66 66
 		$langs->load("bills");
67 67
 
@@ -92,39 +92,39 @@  discard block
 block discarded – undo
92 92
 		$texte .= '</form>';
93 93
 
94 94
 		return $texte;
95
-    }
95
+	}
96 96
 
97
-    /**
98
-     *  Return an example of numbering
99
-     *
100
-     *  @return     string      Example
101
-     */
102
-    public function getExample()
103
-    {
104
-     	global $db, $conf, $langs, $user;
97
+	/**
98
+	 *  Return an example of numbering
99
+	 *
100
+	 *  @return     string      Example
101
+	 */
102
+	public function getExample()
103
+	{
104
+	 	global $db, $conf, $langs, $user;
105 105
 
106
-     	$exp = new ExpenseReport($db);
107
-     	$exp->initAsSpecimen();
108
-     	$exp->fk_user_author = $user->id;
106
+	 	$exp = new ExpenseReport($db);
107
+	 	$exp->initAsSpecimen();
108
+	 	$exp->fk_user_author = $user->id;
109 109
 
110
-     	$numExample = $this->getNextValue($exp);
110
+	 	$numExample = $this->getNextValue($exp);
111 111
 
112 112
 		if (!$numExample)
113 113
 		{
114 114
 			$numExample = $langs->trans('NotConfigured');
115 115
 		}
116 116
 		return $numExample;
117
-    }
118
-
119
-    /**
120
-     *  Return next free value
121
-     *
122
-     *  @param  Object      $object     Object we need next value for
123
-     *  @return string                  Value if KO, <0 if KO
124
-     */
125
-    public function getNextValue($object)
126
-    {
127
-        global $db, $conf;
117
+	}
118
+
119
+	/**
120
+	 *  Return next free value
121
+	 *
122
+	 *  @param  Object      $object     Object we need next value for
123
+	 *  @return string                  Value if KO, <0 if KO
124
+	 */
125
+	public function getNextValue($object)
126
+	{
127
+		global $db, $conf;
128 128
 
129 129
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
130 130
 
@@ -154,5 +154,5 @@  discard block
 block discarded – undo
154 154
 		$numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser);
155 155
 
156 156
 		return $numFinal;
157
-    }
157
+	}
158 158
 }
Please login to merge, or discard this patch.
htdocs/core/modules/modBom.class.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -320,7 +320,10 @@
 block discarded – undo
320 320
 		global $conf, $langs;
321 321
 
322 322
 		$result = $this->_load_tables('/bom/sql/');
323
-		if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')
323
+		if ($result < 0) {
324
+			return -1;
325
+		}
326
+		// Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')
324 327
 
325 328
 		// Create extrafields
326 329
 		//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
Please login to merge, or discard this patch.
htdocs/core/actions_changeselectedfields.inc.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,11 @@
 block discarded – undo
34 34
 
35 35
     $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
36 36
 
37
-    if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
38
-    else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
37
+    if (GETPOST("selectedfields")) {
38
+    	$tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
39
+    } else {
40
+    	$tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
41
+    }
39 42
 
40 43
     include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 44
 
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@
 block discarded – undo
30 30
 // Save selection
31 31
 if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields')
32 32
 {
33
-    $tabparam = array();
33
+	$tabparam = array();
34 34
 
35
-    $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
35
+	$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
36 36
 
37
-    if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
38
-    else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
37
+	if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
38
+	else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
39 39
 
40
-    include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40
+	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 41
 
42
-    $result = dol_set_user_param($db, $conf, $user, $tabparam);
42
+	$result = dol_set_user_param($db, $conf, $user, $tabparam);
43 43
 
44
-    //$action='list';
45
-    //var_dump($tabparam);exit;
44
+	//$action='list';
45
+	//var_dump($tabparam);exit;
46 46
 }
Please login to merge, or discard this patch.
htdocs/core/lib/signature.lib.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	global $conf, $langs;
30 30
 
31 31
 	// Load translation files required by the page
32
-    $langs->loadLangs(array("payment", "paybox"));
32
+	$langs->loadLangs(array("payment", "paybox"));
33 33
 
34 34
 	$servicename = 'Online';
35 35
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,15 +59,22 @@  discard block
 block discarded – undo
59 59
 	if ($type == 'proposal')
60 60
 	{
61 61
 		$out = DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<font color="#666666">' : '');
62
-		if ($mode == 1) $out .= 'proposal_ref';
63
-		if ($mode == 0) $out .= urlencode($ref);
62
+		if ($mode == 1) {
63
+			$out .= 'proposal_ref';
64
+		}
65
+		if ($mode == 0) {
66
+			$out .= urlencode($ref);
67
+		}
64 68
 		$out .= ($mode ? '</font>' : '');
65
-		if ($mode == 1) $out .= '&hashp=<font color="#666666">hash_of_file</font>';
66
-		else {
69
+		if ($mode == 1) {
70
+			$out .= '&hashp=<font color="#666666">hash_of_file</font>';
71
+		} else {
67 72
 			include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
68 73
 			$propaltmp = new Propal($db);
69 74
 			$res = $propaltmp->fetch(0, $ref);
70
-			if ($res <= 0) return 'FailedToGetProposal';
75
+			if ($res <= 0) {
76
+				return 'FailedToGetProposal';
77
+			}
71 78
 
72 79
 			include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
73 80
 			$ecmfile = new EcmFiles($db);
@@ -86,7 +93,10 @@  discard block
 block discarded – undo
86 93
 	}
87 94
 
88 95
 	// For multicompany
89
-	if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
96
+	if (!empty($out)) {
97
+		$out .= "&entity=".$conf->entity;
98
+	}
99
+	// Check the entity because He may be the same reference in several entities
90 100
 
91 101
 	return $out;
92 102
 }
Please login to merge, or discard this patch.
htdocs/loan/note.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@
 block discarded – undo
44 44
 $result = restrictedArea($user, 'loan', $id, '&loan');
45 45
 
46 46
 $object = new Loan($db);
47
-if ($id > 0) $object->fetch($id);
47
+if ($id > 0) {
48
+	$object->fetch($id);
49
+}
48 50
 
49 51
 $permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php
50 52
 
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 
69 69
 if ($id > 0)
70 70
 {
71
-    /*
71
+	/*
72 72
      * Affichage onglets
73 73
      */
74 74
 	$totalpaid = $object->getSumPayment();
75 75
 
76
-    $head = loan_prepare_head($object);
76
+	$head = loan_prepare_head($object);
77 77
 
78
-    print dol_get_fiche_head($head, 'note', $langs->trans("Loan"), -1, 'bill');
78
+	print dol_get_fiche_head($head, 'note', $langs->trans("Loan"), -1, 'bill');
79 79
 
80 80
 	$morehtmlref = '<div class="refidno">';
81 81
 	// Ref loan
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	print '<div class="fichecenter">';
123 123
 	print '<div class="underbanner clearboth"></div>';
124 124
 
125
-    $cssclass = 'titlefield';
126
-    $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php
127
-    include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
125
+	$cssclass = 'titlefield';
126
+	$permission = $user->rights->loan->write; // Used by the include of notes.tpl.php
127
+	include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
128 128
 
129
-    print dol_get_fiche_end();
129
+	print dol_get_fiche_end();
130 130
 }
131 131
 
132 132
 // End of page
Please login to merge, or discard this patch.
htdocs/exports/index.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 print '<div class="center">';
51 51
 if (count($export->array_export_code))
52 52
 {
53
-    print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', $user->rights->export->creer);
53
+	print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', $user->rights->export->creer);
54 54
 }
55 55
 print '</div>';
56 56
 print '<br>';
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 
74 74
 foreach ($liste as $key => $val)
75 75
 {
76
-    if (preg_match('/__\(Disabled\)__/', $liste[$key]))
77
-    {
78
-    	$liste[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
79
-    }
76
+	if (preg_match('/__\(Disabled\)__/', $liste[$key]))
77
+	{
78
+		$liste[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
79
+	}
80 80
 
81 81
 	print '<tr class="oddeven">';
82 82
 	print '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
Please login to merge, or discard this patch.
htdocs/comm/mailing/list.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 // List of fields to search into when doing a "search in all"
61 61
 $fieldstosearchall = array(
62
-    'm.titre'=>'Ref',
62
+	'm.titre'=>'Ref',
63 63
 );
64 64
 
65 65
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	$newcardbutton = '';
158 158
 	if ($user->rights->mailing->creer)
159 159
 	{
160
-        $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
160
+		$newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
161 161
 	}
162 162
 
163 163
 	$i = 0;
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 
178 178
 	$moreforfilter = '';
179 179
 
180
-    print '<div class="div-table-responsive">';
181
-    print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
180
+	print '<div class="div-table-responsive">';
181
+	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
182 182
 
183 183
 	print '<tr class="liste_titre_filter">';
184 184
 	print '<td class="liste_titre">';
Please login to merge, or discard this patch.
Braces   +70 added lines, -25 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
 $offset = $limit * $page;
41 41
 $pageprev = $page - 1;
42 42
 $pagenext = $page + 1;
43
-if (!$sortorder) $sortorder = "DESC";
44
-if (!$sortfield) $sortfield = "m.date_creat";
43
+if (!$sortorder) {
44
+	$sortorder = "DESC";
45
+}
46
+if (!$sortfield) {
47
+	$sortfield = "m.date_creat";
48
+}
45 49
 
46 50
 $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
47 51
 $search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha");
@@ -75,7 +79,9 @@  discard block
 block discarded – undo
75 79
 
76 80
 $parameters = array();
77 81
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
78
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
82
+if ($reshook < 0) {
83
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
84
+}
79 85
 
80 86
 if (empty($reshook))
81 87
 {
@@ -83,13 +89,15 @@  discard block
 block discarded – undo
83 89
 	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
84 90
 
85 91
 	// Purge search criteria
86
-	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
92
+	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
93
+		// All tests are required to be compatible with all browsers
87 94
 	{
88 95
 		/*foreach($object->fields as $key => $val)
89 96
 		{
90 97
 			$search[$key]='';
91 98
 		}*/
92 99
 		$search_ref = '';
100
+	}
93 101
 		$search_all = '';
94 102
 		$toselect = '';
95 103
 		$search_array_options = array();
@@ -126,19 +134,35 @@  discard block
 block discarded – undo
126 134
 	$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
127 135
 	$sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
128 136
 	$sql .= " AND mc.email = '".$db->escape($filteremail)."'";
129
-	if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
130
-	if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
131
-	if (!$sortorder) $sortorder = "ASC";
132
-	if (!$sortfield) $sortfield = "m.rowid";
133
-} else {
137
+	if ($search_ref) {
138
+		$sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
139
+	}
140
+	if ($search_all) {
141
+		$sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
142
+	}
143
+	if (!$sortorder) {
144
+		$sortorder = "ASC";
145
+	}
146
+	if (!$sortfield) {
147
+		$sortfield = "m.rowid";
148
+	}
149
+	} else {
134 150
 	$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
135 151
 	$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
136 152
 	$sql .= " WHERE m.entity = ".$conf->entity;
137
-	if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
138
-	if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
139
-	if (!$sortorder) $sortorder = "ASC";
140
-	if (!$sortfield) $sortfield = "m.rowid";
141
-}
153
+	if ($search_ref) {
154
+		$sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
155
+	}
156
+	if ($search_all) {
157
+		$sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
158
+	}
159
+	if (!$sortorder) {
160
+		$sortorder = "ASC";
161
+	}
162
+	if (!$sortfield) {
163
+		$sortfield = "m.rowid";
164
+	}
165
+	}
142 166
 
143 167
 $sql .= $db->order($sortfield, $sortorder);
144 168
 
@@ -147,9 +171,11 @@  discard block
 block discarded – undo
147 171
 {
148 172
 	$resql = $db->query($sql);
149 173
 	$nbtotalofrecords = $db->num_rows($resql);
150
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
174
+	if (($page * $limit) > $nbtotalofrecords) {
175
+		// if total resultset is smaller then paging size (filtering), goto and load page 0
151 176
 	{
152 177
 		$page = 0;
178
+	}
153 179
 		$offset = 0;
154 180
 	}
155 181
 }
@@ -164,7 +190,9 @@  discard block
 block discarded – undo
164 190
 	$num = $db->num_rows($resql);
165 191
 
166 192
 	$title = $langs->trans("ListOfEMailings");
167
-	if ($filteremail) $title .= ' ('.$langs->trans("SentTo", $filteremail).')';
193
+	if ($filteremail) {
194
+		$title .= ' ('.$langs->trans("SentTo", $filteremail).')';
195
+	}
168 196
 
169 197
 	$newcardbutton = '';
170 198
 	if ($user->rights->mailing->creer)
@@ -175,12 +203,20 @@  discard block
 block discarded – undo
175 203
 	$i = 0;
176 204
 
177 205
 	$param = "&search_all=".urlencode($search_all);
178
-	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
179
-	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
180
-	if ($filteremail) $param .= '&filteremail='.urlencode($filteremail);
206
+	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
207
+		$param .= '&contextpage='.urlencode($contextpage);
208
+	}
209
+	if ($limit > 0 && $limit != $conf->liste_limit) {
210
+		$param .= '&limit='.urlencode($limit);
211
+	}
212
+	if ($filteremail) {
213
+		$param .= '&filteremail='.urlencode($filteremail);
214
+	}
181 215
 
182 216
 	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
183
-	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
217
+	if ($optioncss != '') {
218
+		print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
219
+	}
184 220
 	print '<input type="hidden" name="token" value="'.newToken().'">';
185 221
 	print '<input type="hidden" name="action" value="list">';
186 222
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@@ -202,7 +238,9 @@  discard block
 block discarded – undo
202 238
 	print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).'">';
203 239
 	print '</td>';
204 240
 	print '<td class="liste_titre">&nbsp;</td>';
205
-	if (!$filteremail) print '<td class="liste_titre">&nbsp;</td>';
241
+	if (!$filteremail) {
242
+		print '<td class="liste_titre">&nbsp;</td>';
243
+	}
206 244
 	print '<td class="liste_titre">&nbsp;</td>';
207 245
 	print '<td class="liste_titre">&nbsp;</td>';
208 246
 	print '<td class="liste_titre maxwidthsearch">';
@@ -215,9 +253,14 @@  discard block
 block discarded – undo
215 253
 	print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder);
216 254
 	print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder);
217 255
 	print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder);
218
-	if (!$filteremail) print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
219
-	if (!$filteremail) print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
220
-	else print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
256
+	if (!$filteremail) {
257
+		print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
258
+	}
259
+	if (!$filteremail) {
260
+		print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
261
+	} else {
262
+		print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
263
+	}
221 264
 	print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", 'class="right"', $sortfield, $sortorder);
222 265
 	print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch ');
223 266
 	print "</tr>\n";
@@ -284,7 +327,9 @@  discard block
 block discarded – undo
284 327
 	}
285 328
 	if (empty($num)) {
286 329
 		$colspan = 6;
287
-		if (!$filteremail) $colspan++;
330
+		if (!$filteremail) {
331
+			$colspan++;
332
+		}
288 333
 		print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
289 334
 	}
290 335
 
Please login to merge, or discard this patch.