Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/core/boxes/box_contracts.php 3 patches
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -31,143 +31,143 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class box_contracts extends ModeleBoxes
33 33
 {
34
-    var $boxcode="lastcontracts";
35
-    var $boximg="object_contract";
36
-    var $boxlabel="BoxLastContracts";
37
-    var $depends = array("contrat");	// conf->contrat->enabled
38
-
39
-    var $db;
40
-    var $param;
41
-
42
-    var $info_box_head = array();
43
-    var $info_box_contents = array();
44
-
45
-
46
-    /**
47
-     *  Constructor
48
-     *
49
-     *  @param  DoliDB  $db         Database handler
50
-     *  @param  string  $param      More parameters
51
-     */
52
-    function __construct($db,$param)
53
-    {
54
-        global $user;
55
-
56
-        $this->db=$db;
57
-
58
-        $this->hidden=! ($user->rights->contrat->lire);
59
-    }
60
-
61
-    /**
62
-     *  Load data for box to show them later
63
-     *
64
-     *  @param	int		$max        Maximum number of records to load
65
-     *  @return	void
66
-     */
67
-    function loadBox($max=5)
68
-    {
69
-    	global $user, $langs, $db, $conf;
70
-
71
-    	$this->max=$max;
72
-
73
-    	include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
74
-
75
-    	$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
76
-
77
-    	if ($user->rights->contrat->lire)
78
-    	{
79
-        	$contractstatic=new Contrat($db);
80
-        	$thirdpartytmp=new Societe($db);
81
-
82
-    	    $sql = "SELECT s.nom as name, s.rowid as socid,";
83
-    		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
84
-    		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
85
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
86
-    		$sql.= " WHERE c.fk_soc = s.rowid";
87
-    		$sql.= " AND c.entity = ".$conf->entity;
88
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
89
-    		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
90
-    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
91
-    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
92
-    		$sql.= $db->plimit($max, 0);
93
-
94
-    		$resql = $db->query($sql);
95
-    		if ($resql)
96
-    		{
97
-    			$num = $db->num_rows($resql);
98
-    			$now=dol_now();
99
-
100
-    			$line = 0;
101
-
102
-    			$langs->load("contracts");
103
-
104
-                while ($line < $num)
105
-                {
106
-    				$objp = $db->fetch_object($resql);
107
-    				$datec=$db->jdate($objp->datec);
108
-    				$dateterm=$db->jdate($objp->fin_validite);
109
-    				$dateclose=$db->jdate($objp->date_cloture);
110
-    				$late = '';
111
-
112
-    				$contractstatic->statut=$objp->fk_statut;
113
-    				$contractstatic->id=$objp->rowid;
114
-    				$contractstatic->ref=$objp->ref;
115
-    				$result=$contractstatic->fetch_lines();
116
-
117
-    				$thirdpartytmp->name = $objp->name;
118
-    				$thirdpartytmp->id = $objp->socid;
119
-
120
-    				// fin_validite is no more on contract but on services
121
-    				// if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
122
-
123
-                    $this->info_box_contents[$line][] = array(
124
-                        'td' => '',
125
-                        'text' => $contractstatic->getNomUrl(1),
126
-                        'text2'=> $late,
127
-                        'asis'=>1
128
-                    );
129
-
130
-                    $this->info_box_contents[$line][] = array(
131
-                        'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
132
-                        'text' => $thirdpartytmp->getNomUrl(1),
133
-                        'asis'=>1
134
-                    );
135
-
136
-                    $this->info_box_contents[$line][] = array(
137
-                        'td' => 'class="right"',
138
-                        'text' => dol_print_date($datec,'day'),
139
-                    );
140
-
141
-                    $this->info_box_contents[$line][] = array(
142
-                        'td' => 'class="nowrap right"',
143
-                        'text' => $contractstatic->getLibStatut(7),
144
-                        'asis'=>1,
145
-                    );
146
-
147
-                    $line++;
148
-                }
149
-
150
-                if ($num==0)
151
-                    $this->info_box_contents[$line][0] = array(
152
-                        'td' => 'align="center opacitymedium"',
153
-                        'text'=>$langs->trans("NoRecordedContracts"),
154
-                    );
155
-
156
-                $db->free($resql);
157
-            } else {
158
-                $this->info_box_contents[0][0] = array(
159
-                    'td' => '',
160
-                    'maxlength'=>500,
161
-                    'text' => ($db->error().' sql='.$sql),
162
-                );
163
-            }
164
-        } else {
165
-            $this->info_box_contents[0][0] = array(
166
-                'td' => 'align="left" class="nohover opacitymedium"',
167
-                'text' => $langs->trans("ReadPermissionNotAllowed")
168
-            );
169
-        }
170
-    }
34
+	var $boxcode="lastcontracts";
35
+	var $boximg="object_contract";
36
+	var $boxlabel="BoxLastContracts";
37
+	var $depends = array("contrat");	// conf->contrat->enabled
38
+
39
+	var $db;
40
+	var $param;
41
+
42
+	var $info_box_head = array();
43
+	var $info_box_contents = array();
44
+
45
+
46
+	/**
47
+	 *  Constructor
48
+	 *
49
+	 *  @param  DoliDB  $db         Database handler
50
+	 *  @param  string  $param      More parameters
51
+	 */
52
+	function __construct($db,$param)
53
+	{
54
+		global $user;
55
+
56
+		$this->db=$db;
57
+
58
+		$this->hidden=! ($user->rights->contrat->lire);
59
+	}
60
+
61
+	/**
62
+	 *  Load data for box to show them later
63
+	 *
64
+	 *  @param	int		$max        Maximum number of records to load
65
+	 *  @return	void
66
+	 */
67
+	function loadBox($max=5)
68
+	{
69
+		global $user, $langs, $db, $conf;
70
+
71
+		$this->max=$max;
72
+
73
+		include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
74
+
75
+		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
76
+
77
+		if ($user->rights->contrat->lire)
78
+		{
79
+			$contractstatic=new Contrat($db);
80
+			$thirdpartytmp=new Societe($db);
81
+
82
+			$sql = "SELECT s.nom as name, s.rowid as socid,";
83
+			$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
84
+			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
85
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
86
+			$sql.= " WHERE c.fk_soc = s.rowid";
87
+			$sql.= " AND c.entity = ".$conf->entity;
88
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
89
+			if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
90
+			if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
91
+			else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
92
+			$sql.= $db->plimit($max, 0);
93
+
94
+			$resql = $db->query($sql);
95
+			if ($resql)
96
+			{
97
+				$num = $db->num_rows($resql);
98
+				$now=dol_now();
99
+
100
+				$line = 0;
101
+
102
+				$langs->load("contracts");
103
+
104
+				while ($line < $num)
105
+				{
106
+					$objp = $db->fetch_object($resql);
107
+					$datec=$db->jdate($objp->datec);
108
+					$dateterm=$db->jdate($objp->fin_validite);
109
+					$dateclose=$db->jdate($objp->date_cloture);
110
+					$late = '';
111
+
112
+					$contractstatic->statut=$objp->fk_statut;
113
+					$contractstatic->id=$objp->rowid;
114
+					$contractstatic->ref=$objp->ref;
115
+					$result=$contractstatic->fetch_lines();
116
+
117
+					$thirdpartytmp->name = $objp->name;
118
+					$thirdpartytmp->id = $objp->socid;
119
+
120
+					// fin_validite is no more on contract but on services
121
+					// if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
122
+
123
+					$this->info_box_contents[$line][] = array(
124
+						'td' => '',
125
+						'text' => $contractstatic->getNomUrl(1),
126
+						'text2'=> $late,
127
+						'asis'=>1
128
+					);
129
+
130
+					$this->info_box_contents[$line][] = array(
131
+						'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
132
+						'text' => $thirdpartytmp->getNomUrl(1),
133
+						'asis'=>1
134
+					);
135
+
136
+					$this->info_box_contents[$line][] = array(
137
+						'td' => 'class="right"',
138
+						'text' => dol_print_date($datec,'day'),
139
+					);
140
+
141
+					$this->info_box_contents[$line][] = array(
142
+						'td' => 'class="nowrap right"',
143
+						'text' => $contractstatic->getLibStatut(7),
144
+						'asis'=>1,
145
+					);
146
+
147
+					$line++;
148
+				}
149
+
150
+				if ($num==0)
151
+					$this->info_box_contents[$line][0] = array(
152
+						'td' => 'align="center opacitymedium"',
153
+						'text'=>$langs->trans("NoRecordedContracts"),
154
+					);
155
+
156
+				$db->free($resql);
157
+			} else {
158
+				$this->info_box_contents[0][0] = array(
159
+					'td' => '',
160
+					'maxlength'=>500,
161
+					'text' => ($db->error().' sql='.$sql),
162
+				);
163
+			}
164
+		} else {
165
+			$this->info_box_contents[0][0] = array(
166
+				'td' => 'align="left" class="nohover opacitymedium"',
167
+				'text' => $langs->trans("ReadPermissionNotAllowed")
168
+			);
169
+		}
170
+	}
171 171
 
172 172
 	/**
173 173
 	 *	Method to show box
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 *  @param	int		$nooutput	No print, only return string
178 178
 	 *	@return	string
179 179
 	 */
180
-    function showBox($head = null, $contents = null, $nooutput=0)
181
-    {
182
-        return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
183
-    }
180
+	function showBox($head = null, $contents = null, $nooutput=0)
181
+	{
182
+		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
183
+	}
184 184
 
185 185
 }
186 186
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class box_contracts extends ModeleBoxes
33 33
 {
34
-    var $boxcode="lastcontracts";
35
-    var $boximg="object_contract";
36
-    var $boxlabel="BoxLastContracts";
37
-    var $depends = array("contrat");	// conf->contrat->enabled
34
+    var $boxcode = "lastcontracts";
35
+    var $boximg = "object_contract";
36
+    var $boxlabel = "BoxLastContracts";
37
+    var $depends = array("contrat"); // conf->contrat->enabled
38 38
 
39 39
     var $db;
40 40
     var $param;
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
      *  @param  DoliDB  $db         Database handler
50 50
      *  @param  string  $param      More parameters
51 51
      */
52
-    function __construct($db,$param)
52
+    function __construct($db, $param)
53 53
     {
54 54
         global $user;
55 55
 
56
-        $this->db=$db;
56
+        $this->db = $db;
57 57
 
58
-        $this->hidden=! ($user->rights->contrat->lire);
58
+        $this->hidden = !($user->rights->contrat->lire);
59 59
     }
60 60
 
61 61
     /**
@@ -64,38 +64,38 @@  discard block
 block discarded – undo
64 64
      *  @param	int		$max        Maximum number of records to load
65 65
      *  @return	void
66 66
      */
67
-    function loadBox($max=5)
67
+    function loadBox($max = 5)
68 68
     {
69 69
     	global $user, $langs, $db, $conf;
70 70
 
71
-    	$this->max=$max;
71
+    	$this->max = $max;
72 72
 
73 73
     	include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
74 74
 
75
-    	$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
75
+    	$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max));
76 76
 
77 77
     	if ($user->rights->contrat->lire)
78 78
     	{
79
-        	$contractstatic=new Contrat($db);
80
-        	$thirdpartytmp=new Societe($db);
79
+        	$contractstatic = new Contrat($db);
80
+        	$thirdpartytmp = new Societe($db);
81 81
 
82 82
     	    $sql = "SELECT s.nom as name, s.rowid as socid,";
83
-    		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
84
-    		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
85
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
86
-    		$sql.= " WHERE c.fk_soc = s.rowid";
87
-    		$sql.= " AND c.entity = ".$conf->entity;
88
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
89
-    		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
90
-    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
91
-    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
92
-    		$sql.= $db->plimit($max, 0);
83
+    		$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
84
+    		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
85
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
86
+    		$sql .= " WHERE c.fk_soc = s.rowid";
87
+    		$sql .= " AND c.entity = ".$conf->entity;
88
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
89
+    		if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
90
+    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC ";
91
+    		else $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
92
+    		$sql .= $db->plimit($max, 0);
93 93
 
94 94
     		$resql = $db->query($sql);
95 95
     		if ($resql)
96 96
     		{
97 97
     			$num = $db->num_rows($resql);
98
-    			$now=dol_now();
98
+    			$now = dol_now();
99 99
 
100 100
     			$line = 0;
101 101
 
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
                 while ($line < $num)
105 105
                 {
106 106
     				$objp = $db->fetch_object($resql);
107
-    				$datec=$db->jdate($objp->datec);
108
-    				$dateterm=$db->jdate($objp->fin_validite);
109
-    				$dateclose=$db->jdate($objp->date_cloture);
107
+    				$datec = $db->jdate($objp->datec);
108
+    				$dateterm = $db->jdate($objp->fin_validite);
109
+    				$dateclose = $db->jdate($objp->date_cloture);
110 110
     				$late = '';
111 111
 
112
-    				$contractstatic->statut=$objp->fk_statut;
113
-    				$contractstatic->id=$objp->rowid;
114
-    				$contractstatic->ref=$objp->ref;
115
-    				$result=$contractstatic->fetch_lines();
112
+    				$contractstatic->statut = $objp->fk_statut;
113
+    				$contractstatic->id = $objp->rowid;
114
+    				$contractstatic->ref = $objp->ref;
115
+    				$result = $contractstatic->fetch_lines();
116 116
 
117 117
     				$thirdpartytmp->name = $objp->name;
118 118
     				$thirdpartytmp->id = $objp->socid;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
                     $this->info_box_contents[$line][] = array(
137 137
                         'td' => 'class="right"',
138
-                        'text' => dol_print_date($datec,'day'),
138
+                        'text' => dol_print_date($datec, 'day'),
139 139
                     );
140 140
 
141 141
                     $this->info_box_contents[$line][] = array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                     $line++;
148 148
                 }
149 149
 
150
-                if ($num==0)
150
+                if ($num == 0)
151 151
                     $this->info_box_contents[$line][0] = array(
152 152
                         'td' => 'align="center opacitymedium"',
153 153
                         'text'=>$langs->trans("NoRecordedContracts"),
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 *  @param	int		$nooutput	No print, only return string
178 178
 	 *	@return	string
179 179
 	 */
180
-    function showBox($head = null, $contents = null, $nooutput=0)
180
+    function showBox($head = null, $contents = null, $nooutput = 0)
181 181
     {
182 182
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
183 183
     }
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -82,13 +82,22 @@  discard block
 block discarded – undo
82 82
     	    $sql = "SELECT s.nom as name, s.rowid as socid,";
83 83
     		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
84 84
     		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
85
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) {
86
+    			$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
87
+    		}
86 88
     		$sql.= " WHERE c.fk_soc = s.rowid";
87 89
     		$sql.= " AND c.entity = ".$conf->entity;
88
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
89
-    		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
90
-    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
91
-    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
90
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) {
91
+    			$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
92
+    		}
93
+    		if($user->societe_id) {
94
+    			$sql.= " AND s.rowid = ".$user->societe_id;
95
+    		}
96
+    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
97
+    			$sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
98
+    		} else {
99
+    			$sql.= " ORDER BY c.tms DESC, c.ref DESC ";
100
+    		}
92 101
     		$sql.= $db->plimit($max, 0);
93 102
 
94 103
     		$resql = $db->query($sql);
@@ -147,11 +156,12 @@  discard block
 block discarded – undo
147 156
                     $line++;
148 157
                 }
149 158
 
150
-                if ($num==0)
151
-                    $this->info_box_contents[$line][0] = array(
159
+                if ($num==0) {
160
+                                    $this->info_box_contents[$line][0] = array(
152 161
                         'td' => 'align="center opacitymedium"',
153 162
                         'text'=>$langs->trans("NoRecordedContracts"),
154 163
                     );
164
+                }
155 165
 
156 166
                 $db->free($resql);
157 167
             } else {
Please login to merge, or discard this patch.
htdocs/core/boxes/box_bookmarks.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	function __construct($db,$param)
50 50
 	{
51
-	    global $user;
51
+		global $user;
52 52
 
53
-	    $this->db=$db;
53
+		$this->db=$db;
54 54
 
55
-	    $this->hidden=! ($user->rights->bookmark->lire);
55
+		$this->hidden=! ($user->rights->bookmark->lire);
56 56
 	}
57 57
 
58 58
 	/**
59
-     *  Load data for box to show them later
60
-     *
61
-     *  @param	int		$max        Maximum number of records to load
62
-     *  @return	void
59
+	 *  Load data for box to show them later
60
+	 *
61
+	 *  @param	int		$max        Maximum number of records to load
62
+	 *  @return	void
63 63
 	 */
64 64
 	function loadBox($max=5)
65 65
 	{
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		$this->max=$max;
70 70
 
71 71
 		$this->info_box_head = array(
72
-            'text' => $langs->trans("BoxMyLastBookmarks",$max),
73
-            'sublink' => DOL_URL_ROOT.'/bookmarks/list.php',
74
-        );
75
-        if ($user->rights->bookmark->creer) {
72
+			'text' => $langs->trans("BoxMyLastBookmarks",$max),
73
+			'sublink' => DOL_URL_ROOT.'/bookmarks/list.php',
74
+		);
75
+		if ($user->rights->bookmark->creer) {
76 76
 			$this->info_box_head['subpicto']='object_bookmark';
77 77
 			$this->info_box_head['subtext']=$langs->trans("BookmarksManagement");
78 78
 		}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			$sql = "SELECT b.title, b.url, b.target, b.favicon";
88 88
 			$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b";
89 89
 			$sql.= " WHERE fk_user = ".$user->id;
90
-            $sql.= " AND b.entity = ".$conf->entity;
90
+			$sql.= " AND b.entity = ".$conf->entity;
91 91
 			$sql.= $db->order("position","ASC");
92 92
 			$sql.= $db->plimit($max, 0);
93 93
 
@@ -98,52 +98,52 @@  discard block
 block discarded – undo
98 98
 
99 99
 				$line = 0;
100 100
 
101
-                while ($line < $num) {
102
-                    $objp = $db->fetch_object($result);
103
-
104
-                    $this->info_box_contents[$line][0] = array(
105
-                        'td' => 'align="left" width="16"',
106
-                        'logo' => $this->boximg,
107
-                        'url' => $objp->url,
108
-                        'tooltip' => $objp->title,
109
-                        'target' => $objp->target?'newtab':'',
110
-                    );
111
-                    $this->info_box_contents[$line][1] = array(
112
-                        'td' => '',
113
-                        'text' => $objp->title,
114
-                        'url' => $objp->url,
115
-                        'tooltip' => $objp->title,
116
-                        'target' => $objp->target?'newtab':'',
117
-                    );
118
-
119
-                    $line++;
120
-                }
121
-
122
-                if ($num==0) {
123
-                    $mytxt=$langs->trans("NoRecordedBookmarks");
124
-                    if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
125
-                    $this->info_box_contents[$line][0] = array(
126
-                        'td' => 'align="center" colspan="2"',
127
-                        'tooltip' => $mytxt,
128
-                        'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt,
129
-                    );
130
-                }
131
-
132
-                $db->free($result);
133
-            } else {
134
-                $this->info_box_contents[0][0] = array(
135
-                    'td' => '',
136
-                    'maxlength'=>500,
137
-                    'text' => ($db->error().' sql='.$sql),
138
-                );
139
-            }
140
-        } else {
141
-            $this->info_box_contents[0][0] = array(
142
-                'td' => 'align="left" class="nohover opacitymedium"',
143
-                'text' => $langs->trans("ReadPermissionNotAllowed")
144
-            );
145
-        }
146
-    }
101
+				while ($line < $num) {
102
+					$objp = $db->fetch_object($result);
103
+
104
+					$this->info_box_contents[$line][0] = array(
105
+						'td' => 'align="left" width="16"',
106
+						'logo' => $this->boximg,
107
+						'url' => $objp->url,
108
+						'tooltip' => $objp->title,
109
+						'target' => $objp->target?'newtab':'',
110
+					);
111
+					$this->info_box_contents[$line][1] = array(
112
+						'td' => '',
113
+						'text' => $objp->title,
114
+						'url' => $objp->url,
115
+						'tooltip' => $objp->title,
116
+						'target' => $objp->target?'newtab':'',
117
+					);
118
+
119
+					$line++;
120
+				}
121
+
122
+				if ($num==0) {
123
+					$mytxt=$langs->trans("NoRecordedBookmarks");
124
+					if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
125
+					$this->info_box_contents[$line][0] = array(
126
+						'td' => 'align="center" colspan="2"',
127
+						'tooltip' => $mytxt,
128
+						'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt,
129
+					);
130
+				}
131
+
132
+				$db->free($result);
133
+			} else {
134
+				$this->info_box_contents[0][0] = array(
135
+					'td' => '',
136
+					'maxlength'=>500,
137
+					'text' => ($db->error().' sql='.$sql),
138
+				);
139
+			}
140
+		} else {
141
+			$this->info_box_contents[0][0] = array(
142
+				'td' => 'align="left" class="nohover opacitymedium"',
143
+				'text' => $langs->trans("ReadPermissionNotAllowed")
144
+			);
145
+		}
146
+	}
147 147
 
148 148
 	/**
149 149
 	 *	Method to show box
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	 *  @param	int		$nooutput	No print, only return string
154 154
 	 *	@return	string
155 155
 	 */
156
-    function showBox($head = null, $contents = null, $nooutput=0)
157
-    {
156
+	function showBox($head = null, $contents = null, $nooutput=0)
157
+	{
158 158
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
159 159
 	}
160 160
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class box_bookmarks extends ModeleBoxes
30 30
 {
31
-	var $boxcode="bookmarks";
32
-	var $boximg="object_bookmark";
33
-	var $boxlabel="BoxMyLastBookmarks";
31
+	var $boxcode = "bookmarks";
32
+	var $boximg = "object_bookmark";
33
+	var $boxlabel = "BoxMyLastBookmarks";
34 34
 	var $depends = array("bookmark");
35 35
 
36 36
 	var $db;
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 	 *  @param  DoliDB  $db         Database handler
47 47
 	 *  @param  string  $param      More parameters
48 48
 	 */
49
-	function __construct($db,$param)
49
+	function __construct($db, $param)
50 50
 	{
51 51
 	    global $user;
52 52
 
53
-	    $this->db=$db;
53
+	    $this->db = $db;
54 54
 
55
-	    $this->hidden=! ($user->rights->bookmark->lire);
55
+	    $this->hidden = !($user->rights->bookmark->lire);
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,35 +61,35 @@  discard block
 block discarded – undo
61 61
      *  @param	int		$max        Maximum number of records to load
62 62
      *  @return	void
63 63
 	 */
64
-	function loadBox($max=5)
64
+	function loadBox($max = 5)
65 65
 	{
66 66
 		global $user, $langs, $db, $conf;
67 67
 		$langs->load("boxes");
68 68
 
69
-		$this->max=$max;
69
+		$this->max = $max;
70 70
 
71 71
 		$this->info_box_head = array(
72
-            'text' => $langs->trans("BoxMyLastBookmarks",$max),
72
+            'text' => $langs->trans("BoxMyLastBookmarks", $max),
73 73
             'sublink' => DOL_URL_ROOT.'/bookmarks/list.php',
74 74
         );
75 75
         if ($user->rights->bookmark->creer) {
76
-			$this->info_box_head['subpicto']='object_bookmark';
77
-			$this->info_box_head['subtext']=$langs->trans("BookmarksManagement");
76
+			$this->info_box_head['subpicto'] = 'object_bookmark';
77
+			$this->info_box_head['subtext'] = $langs->trans("BookmarksManagement");
78 78
 		}
79 79
 		else
80 80
 		{
81
-			$this->info_box_head['subpicto']='object_bookmark';
82
-			$this->info_box_head['subtext']=$langs->trans("ListOfBookmark");
81
+			$this->info_box_head['subpicto'] = 'object_bookmark';
82
+			$this->info_box_head['subtext'] = $langs->trans("ListOfBookmark");
83 83
 		}
84 84
 
85 85
 		if ($user->rights->bookmark->lire)
86 86
 		{
87 87
 			$sql = "SELECT b.title, b.url, b.target, b.favicon";
88
-			$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b";
89
-			$sql.= " WHERE fk_user = ".$user->id;
90
-            $sql.= " AND b.entity = ".$conf->entity;
91
-			$sql.= $db->order("position","ASC");
92
-			$sql.= $db->plimit($max, 0);
88
+			$sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b";
89
+			$sql .= " WHERE fk_user = ".$user->id;
90
+            $sql .= " AND b.entity = ".$conf->entity;
91
+			$sql .= $db->order("position", "ASC");
92
+			$sql .= $db->plimit($max, 0);
93 93
 
94 94
 			$result = $db->query($sql);
95 95
 			if ($result)
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
                         'logo' => $this->boximg,
107 107
                         'url' => $objp->url,
108 108
                         'tooltip' => $objp->title,
109
-                        'target' => $objp->target?'newtab':'',
109
+                        'target' => $objp->target ? 'newtab' : '',
110 110
                     );
111 111
                     $this->info_box_contents[$line][1] = array(
112 112
                         'td' => '',
113 113
                         'text' => $objp->title,
114 114
                         'url' => $objp->url,
115 115
                         'tooltip' => $objp->title,
116
-                        'target' => $objp->target?'newtab':'',
116
+                        'target' => $objp->target ? 'newtab' : '',
117 117
                     );
118 118
 
119 119
                     $line++;
120 120
                 }
121 121
 
122
-                if ($num==0) {
123
-                    $mytxt=$langs->trans("NoRecordedBookmarks");
124
-                    if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
122
+                if ($num == 0) {
123
+                    $mytxt = $langs->trans("NoRecordedBookmarks");
124
+                    if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd");
125 125
                     $this->info_box_contents[$line][0] = array(
126 126
                         'td' => 'align="center" colspan="2"',
127 127
                         'tooltip' => $mytxt,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 *  @param	int		$nooutput	No print, only return string
154 154
 	 *	@return	string
155 155
 	 */
156
-    function showBox($head = null, $contents = null, $nooutput=0)
156
+    function showBox($head = null, $contents = null, $nooutput = 0)
157 157
     {
158 158
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
159 159
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,8 +75,7 @@  discard block
 block discarded – undo
75 75
         if ($user->rights->bookmark->creer) {
76 76
 			$this->info_box_head['subpicto']='object_bookmark';
77 77
 			$this->info_box_head['subtext']=$langs->trans("BookmarksManagement");
78
-		}
79
-		else
78
+		} else
80 79
 		{
81 80
 			$this->info_box_head['subpicto']='object_bookmark';
82 81
 			$this->info_box_head['subtext']=$langs->trans("ListOfBookmark");
@@ -121,7 +120,9 @@  discard block
 block discarded – undo
121 120
 
122 121
                 if ($num==0) {
123 122
                     $mytxt=$langs->trans("NoRecordedBookmarks");
124
-                    if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
123
+                    if ($user->rights->bookmark->creer) {
124
+                    	$mytxt.=' '.$langs->trans("ClickToAdd");
125
+                    }
125 126
                     $this->info_box_contents[$line][0] = array(
126 127
                         'td' => 'align="center" colspan="2"',
127 128
                         'tooltip' => $mytxt,
Please login to merge, or discard this patch.
htdocs/core/boxes/box_factures.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function __construct($db,$param)
52 52
 	{
53
-	    global $user;
53
+		global $user;
54 54
 
55
-	    $this->db=$db;
55
+		$this->db=$db;
56 56
 
57
-	    $this->hidden=! ($user->rights->facture->lire);
57
+		$this->hidden=! ($user->rights->facture->lire);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 *  Load data into info_box_contents array to show array later.
62 62
 	 *
63 63
 	 *  @param	int		$max        Maximum number of records to load
64
-     *  @return	void
64
+	 *  @return	void
65 65
 	 */
66 66
 	function loadBox($max=5)
67 67
 	{
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 
70 70
 		$this->max=$max;
71 71
 
72
-        include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
73
-        include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
72
+		include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
73
+		include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
74 74
 
75
-        $facturestatic=new Facture($db);
76
-        $societestatic = new Societe($db);
75
+		$facturestatic=new Facture($db);
76
+		$societestatic = new Societe($db);
77 77
 
78 78
 		$text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max);
79 79
 		$this->info_box_head = array(
@@ -81,16 +81,16 @@  discard block
 block discarded – undo
81 81
 				'limit'=> dol_strlen($text)
82 82
 		);
83 83
 
84
-        if ($user->rights->facture->lire) {
85
-            $sql = "SELECT f.rowid as facid";
86
-            $sql.= ", f.facnumber, f.type, f.total as total_ht";
87
-            $sql.= ", f.tva as total_tva";
88
-            $sql.= ", f.total_ttc";
89
-            $sql.= ", f.datef as df";
84
+		if ($user->rights->facture->lire) {
85
+			$sql = "SELECT f.rowid as facid";
86
+			$sql.= ", f.facnumber, f.type, f.total as total_ht";
87
+			$sql.= ", f.tva as total_tva";
88
+			$sql.= ", f.total_ttc";
89
+			$sql.= ", f.datef as df";
90 90
 			$sql.= ", f.paye, f.fk_statut, f.datec, f.tms";
91
-            $sql.= ", s.nom as name";
92
-            $sql.= ", s.rowid as socid";
93
-            $sql.= ", s.code_client";
91
+			$sql.= ", s.nom as name";
92
+			$sql.= ", s.rowid as socid";
93
+			$sql.= ", s.code_client";
94 94
 			$sql.= ", f.date_lim_reglement as datelimite";
95 95
 			$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
96 96
 			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 			$sql.= " AND f.entity = ".$conf->entity;
100 100
 			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
101 101
 			if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
102
-            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
103
-            else $sql.= " ORDER BY f.tms DESC, f.facnumber DESC ";
102
+			if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
103
+			else $sql.= " ORDER BY f.tms DESC, f.facnumber DESC ";
104 104
 			$sql.= $db->plimit($max, 0);
105 105
 
106 106
 			$result = $db->query($sql);
@@ -112,83 +112,83 @@  discard block
 block discarded – undo
112 112
 				$line = 0;
113 113
 				$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)';
114 114
 
115
-                while ($line < $num) {
116
-                    $objp = $db->fetch_object($result);
117
-                    $datelimite = $db->jdate($objp->datelimite);
118
-                    $date = $db->jdate($objp->df);
119
-                    $datem = $db->jdate($objp->tms);
120
-                    $facturestatic->id = $objp->facid;
121
-                    $facturestatic->ref = $objp->facnumber;
122
-                    $facturestatic->type = $objp->type;
123
-                    $facturestatic->total_ht = $objp->total_ht;
124
-                    $facturestatic->total_tva = $objp->total_tva;
125
-                    $facturestatic->total_ttc = $objp->total_ttc;
126
-                    $facturestatic->statut = $objp->fk_statut;
127
-                    $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
128
-
129
-                    $societestatic->id = $objp->socid;
130
-                    $societestatic->name = $objp->name;
131
-                    $societestatic->code_client = $objp->code_client;
115
+				while ($line < $num) {
116
+					$objp = $db->fetch_object($result);
117
+					$datelimite = $db->jdate($objp->datelimite);
118
+					$date = $db->jdate($objp->df);
119
+					$datem = $db->jdate($objp->tms);
120
+					$facturestatic->id = $objp->facid;
121
+					$facturestatic->ref = $objp->facnumber;
122
+					$facturestatic->type = $objp->type;
123
+					$facturestatic->total_ht = $objp->total_ht;
124
+					$facturestatic->total_tva = $objp->total_tva;
125
+					$facturestatic->total_ttc = $objp->total_ttc;
126
+					$facturestatic->statut = $objp->fk_statut;
127
+					$facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
128
+
129
+					$societestatic->id = $objp->socid;
130
+					$societestatic->name = $objp->name;
131
+					$societestatic->code_client = $objp->code_client;
132 132
 
133 133
 
134 134
 					$late = '';
135 135
 					if ($facturestatic->hasDelay()) {
136
-                        $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day')));
137
-                    }
138
-
139
-                    $this->info_box_contents[$line][] = array(
140
-                        'td' => '',
141
-                        'text' => $facturestatic->getNomUrl(1),
142
-                        'text2'=> $late,
143
-                        'asis' => 1,
144
-                    );
145
-
146
-                    $this->info_box_contents[$line][] = array(
147
-                        'td' => '',
148
-                        'text' => $societestatic->getNomUrl(1, '', 40),
149
-                        'asis' => 1,
150
-                    );
151
-
152
-                    $this->info_box_contents[$line][] = array(
153
-                        'td' => 'class="right"',
154
-                        'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
155
-                    );
156
-
157
-                    $this->info_box_contents[$line][] = array(
158
-                        'td' => 'class="right"',
159
-                        'text' => dol_print_date($date,'day'),
160
-                    );
161
-
162
-                    $this->info_box_contents[$line][] = array(
163
-                        'td' => 'align="right" width="18"',
164
-                        'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3),
165
-                    );
166
-
167
-                    $line++;
168
-                }
169
-
170
-                if ($num==0)
171
-                    $this->info_box_contents[$line][0] = array(
172
-                        'td' => 'align="center"',
173
-                        'text'=>$langs->trans("NoRecordedInvoices"),
174
-                    );
175
-
176
-                $db->free($result);
177
-            } else {
178
-                $this->info_box_contents[0][0] = array(
179
-                    'td' => '',
180
-                    'maxlength'=>500,
181
-                    'text' => ($db->error().' sql='.$sql),
182
-                );
183
-            }
184
-
185
-        } else {
186
-            $this->info_box_contents[0][0] = array(
187
-                'td' => 'align="left" class="nohover opacitymedium"',
188
-                'text' => $langs->trans("ReadPermissionNotAllowed")
189
-            );
190
-        }
191
-    }
136
+						$late = img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day')));
137
+					}
138
+
139
+					$this->info_box_contents[$line][] = array(
140
+						'td' => '',
141
+						'text' => $facturestatic->getNomUrl(1),
142
+						'text2'=> $late,
143
+						'asis' => 1,
144
+					);
145
+
146
+					$this->info_box_contents[$line][] = array(
147
+						'td' => '',
148
+						'text' => $societestatic->getNomUrl(1, '', 40),
149
+						'asis' => 1,
150
+					);
151
+
152
+					$this->info_box_contents[$line][] = array(
153
+						'td' => 'class="right"',
154
+						'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
155
+					);
156
+
157
+					$this->info_box_contents[$line][] = array(
158
+						'td' => 'class="right"',
159
+						'text' => dol_print_date($date,'day'),
160
+					);
161
+
162
+					$this->info_box_contents[$line][] = array(
163
+						'td' => 'align="right" width="18"',
164
+						'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3),
165
+					);
166
+
167
+					$line++;
168
+				}
169
+
170
+				if ($num==0)
171
+					$this->info_box_contents[$line][0] = array(
172
+						'td' => 'align="center"',
173
+						'text'=>$langs->trans("NoRecordedInvoices"),
174
+					);
175
+
176
+				$db->free($result);
177
+			} else {
178
+				$this->info_box_contents[0][0] = array(
179
+					'td' => '',
180
+					'maxlength'=>500,
181
+					'text' => ($db->error().' sql='.$sql),
182
+				);
183
+			}
184
+
185
+		} else {
186
+			$this->info_box_contents[0][0] = array(
187
+				'td' => 'align="left" class="nohover opacitymedium"',
188
+				'text' => $langs->trans("ReadPermissionNotAllowed")
189
+			);
190
+		}
191
+	}
192 192
 
193 193
 	/**
194 194
 	 *  Method to show box
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 *  @param	int		$nooutput	No print, only return string
199 199
 	 *	@return	string
200 200
 	 */
201
-    function showBox($head = null, $contents = null, $nooutput=0)
202
-    {
201
+	function showBox($head = null, $contents = null, $nooutput=0)
202
+	{
203 203
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
204 204
 	}
205 205
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class box_factures extends ModeleBoxes
32 32
 {
33
-	var $boxcode="lastcustomerbills";
34
-	var $boximg="object_bill";
35
-	var $boxlabel="BoxLastCustomerBills";
33
+	var $boxcode = "lastcustomerbills";
34
+	var $boximg = "object_bill";
35
+	var $boxlabel = "BoxLastCustomerBills";
36 36
 	var $depends = array("facture");
37 37
 
38 38
 	var $db;
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 *  @param  DoliDB  $db         Database handler
49 49
 	 *  @param  string  $param      More parameters
50 50
 	 */
51
-	function __construct($db,$param)
51
+	function __construct($db, $param)
52 52
 	{
53 53
 	    global $user;
54 54
 
55
-	    $this->db=$db;
55
+	    $this->db = $db;
56 56
 
57
-	    $this->hidden=! ($user->rights->facture->lire);
57
+	    $this->hidden = !($user->rights->facture->lire);
58 58
 	}
59 59
 
60 60
 	/**
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 	 *  @param	int		$max        Maximum number of records to load
64 64
      *  @return	void
65 65
 	 */
66
-	function loadBox($max=5)
66
+	function loadBox($max = 5)
67 67
 	{
68 68
 		global $conf, $user, $langs, $db;
69 69
 
70
-		$this->max=$max;
70
+		$this->max = $max;
71 71
 
72 72
         include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
73 73
         include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
74 74
 
75
-        $facturestatic=new Facture($db);
75
+        $facturestatic = new Facture($db);
76 76
         $societestatic = new Societe($db);
77 77
 
78
-		$text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max);
78
+		$text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max);
79 79
 		$this->info_box_head = array(
80 80
 				'text' => $text,
81 81
 				'limit'=> dol_strlen($text)
@@ -83,31 +83,31 @@  discard block
 block discarded – undo
83 83
 
84 84
         if ($user->rights->facture->lire) {
85 85
             $sql = "SELECT f.rowid as facid";
86
-            $sql.= ", f.facnumber, f.type, f.total as total_ht";
87
-            $sql.= ", f.tva as total_tva";
88
-            $sql.= ", f.total_ttc";
89
-            $sql.= ", f.datef as df";
90
-			$sql.= ", f.paye, f.fk_statut, f.datec, f.tms";
91
-            $sql.= ", s.nom as name";
92
-            $sql.= ", s.rowid as socid";
93
-            $sql.= ", s.code_client";
94
-			$sql.= ", f.date_lim_reglement as datelimite";
95
-			$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
96
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
97
-			$sql.= ")";
98
-			$sql.= " WHERE f.fk_soc = s.rowid";
99
-			$sql.= " AND f.entity = ".$conf->entity;
100
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
101
-			if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
102
-            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
103
-            else $sql.= " ORDER BY f.tms DESC, f.facnumber DESC ";
104
-			$sql.= $db->plimit($max, 0);
86
+            $sql .= ", f.facnumber, f.type, f.total as total_ht";
87
+            $sql .= ", f.tva as total_tva";
88
+            $sql .= ", f.total_ttc";
89
+            $sql .= ", f.datef as df";
90
+			$sql .= ", f.paye, f.fk_statut, f.datec, f.tms";
91
+            $sql .= ", s.nom as name";
92
+            $sql .= ", s.rowid as socid";
93
+            $sql .= ", s.code_client";
94
+			$sql .= ", f.date_lim_reglement as datelimite";
95
+			$sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
96
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
97
+			$sql .= ")";
98
+			$sql .= " WHERE f.fk_soc = s.rowid";
99
+			$sql .= " AND f.entity = ".$conf->entity;
100
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
101
+			if ($user->societe_id)	$sql .= " AND s.rowid = ".$user->societe_id;
102
+            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.facnumber DESC ";
103
+            else $sql .= " ORDER BY f.tms DESC, f.facnumber DESC ";
104
+			$sql .= $db->plimit($max, 0);
105 105
 
106 106
 			$result = $db->query($sql);
107 107
 			if ($result)
108 108
 			{
109 109
 				$num = $db->num_rows($result);
110
-				$now=dol_now();
110
+				$now = dol_now();
111 111
 
112 112
 				$line = 0;
113 113
 				$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)';
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
 					$late = '';
135 135
 					if ($facturestatic->hasDelay()) {
136
-                        $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day')));
136
+                        $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day')));
137 137
                     }
138 138
 
139 139
                     $this->info_box_contents[$line][] = array(
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
 
157 157
                     $this->info_box_contents[$line][] = array(
158 158
                         'td' => 'class="right"',
159
-                        'text' => dol_print_date($date,'day'),
159
+                        'text' => dol_print_date($date, 'day'),
160 160
                     );
161 161
 
162 162
                     $this->info_box_contents[$line][] = array(
163 163
                         'td' => 'align="right" width="18"',
164
-                        'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3),
164
+                        'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3),
165 165
                     );
166 166
 
167 167
                     $line++;
168 168
                 }
169 169
 
170
-                if ($num==0)
170
+                if ($num == 0)
171 171
                     $this->info_box_contents[$line][0] = array(
172 172
                         'td' => 'align="center"',
173 173
                         'text'=>$langs->trans("NoRecordedInvoices"),
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 *  @param	int		$nooutput	No print, only return string
199 199
 	 *	@return	string
200 200
 	 */
201
-    function showBox($head = null, $contents = null, $nooutput=0)
201
+    function showBox($head = null, $contents = null, $nooutput = 0)
202 202
     {
203 203
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
204 204
 	}
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -93,14 +93,23 @@  discard block
 block discarded – undo
93 93
             $sql.= ", s.code_client";
94 94
 			$sql.= ", f.date_lim_reglement as datelimite";
95 95
 			$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
96
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
96
+			if (!$user->rights->societe->client->voir && !$user->societe_id) {
97
+				$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
98
+			}
97 99
 			$sql.= ")";
98 100
 			$sql.= " WHERE f.fk_soc = s.rowid";
99 101
 			$sql.= " AND f.entity = ".$conf->entity;
100
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
101
-			if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
102
-            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
103
-            else $sql.= " ORDER BY f.tms DESC, f.facnumber DESC ";
102
+			if (!$user->rights->societe->client->voir && !$user->societe_id) {
103
+				$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
104
+			}
105
+			if($user->societe_id) {
106
+				$sql.= " AND s.rowid = ".$user->societe_id;
107
+			}
108
+            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
109
+            	$sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
110
+            } else {
111
+            	$sql.= " ORDER BY f.tms DESC, f.facnumber DESC ";
112
+            }
104 113
 			$sql.= $db->plimit($max, 0);
105 114
 
106 115
 			$result = $db->query($sql);
@@ -167,11 +176,12 @@  discard block
 block discarded – undo
167 176
                     $line++;
168 177
                 }
169 178
 
170
-                if ($num==0)
171
-                    $this->info_box_contents[$line][0] = array(
179
+                if ($num==0) {
180
+                                    $this->info_box_contents[$line][0] = array(
172 181
                         'td' => 'align="center"',
173 182
                         'text'=>$langs->trans("NoRecordedInvoices"),
174 183
                     );
184
+                }
175 185
 
176 186
                 $db->free($result);
177 187
             } else {
Please login to merge, or discard this patch.
htdocs/core/boxes/box_services_expired.php 3 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -30,137 +30,137 @@  discard block
 block discarded – undo
30 30
 class box_services_expired extends ModeleBoxes
31 31
 {
32 32
 
33
-    var $boxcode="expiredservices";     // id of box
34
-    var $boximg="object_contract";
35
-    var $boxlabel="BoxOldestExpiredServices";
36
-    var $depends = array("contrat");	// conf->propal->enabled
33
+	var $boxcode="expiredservices";     // id of box
34
+	var $boximg="object_contract";
35
+	var $boxlabel="BoxOldestExpiredServices";
36
+	var $depends = array("contrat");	// conf->propal->enabled
37 37
 
38
-    var $db;
39
-    var $param;
38
+	var $db;
39
+	var $param;
40 40
 
41
-    var $info_box_head = array();
42
-    var $info_box_contents = array();
41
+	var $info_box_head = array();
42
+	var $info_box_contents = array();
43 43
 
44 44
 
45
-    /**
46
-     *  Constructor
47
-     *
48
-     *  @param  DoliDB  $db         Database handler
49
-     *  @param  string  $param      More parameters
50
-     */
51
-    function __construct($db,$param)
52
-    {
53
-        global $user;
45
+	/**
46
+	 *  Constructor
47
+	 *
48
+	 *  @param  DoliDB  $db         Database handler
49
+	 *  @param  string  $param      More parameters
50
+	 */
51
+	function __construct($db,$param)
52
+	{
53
+		global $user;
54 54
 
55
-        $this->db=$db;
55
+		$this->db=$db;
56 56
 
57
-        $this->hidden=! ($user->rights->contrat->lire);
58
-    }
57
+		$this->hidden=! ($user->rights->contrat->lire);
58
+	}
59 59
 
60
-    /**
61
-     *  Load data for box to show them later
62
-     *
63
-     *  @param	int		$max        Maximum number of records to load
64
-     *  @return	void
65
-     */
66
-    function loadBox($max=5)
67
-    {
68
-    	global $user, $langs, $db, $conf;
60
+	/**
61
+	 *  Load data for box to show them later
62
+	 *
63
+	 *  @param	int		$max        Maximum number of records to load
64
+	 *  @return	void
65
+	 */
66
+	function loadBox($max=5)
67
+	{
68
+		global $user, $langs, $db, $conf;
69 69
 
70
-    	$this->max=$max;
70
+		$this->max=$max;
71 71
 
72
-    	$now=dol_now();
72
+		$now=dol_now();
73 73
 
74
-    	$this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices",$max));
74
+		$this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices",$max));
75 75
 
76
-    	if ($user->rights->contrat->lire)
77
-    	{
78
-    	    // Select contracts with at least one expired service
76
+		if ($user->rights->contrat->lire)
77
+		{
78
+			// Select contracts with at least one expired service
79 79
 			$sql = "SELECT ";
80
-    		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat,";
80
+			$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat,";
81 81
 			$sql.= " s.nom as name, s.rowid as socid,";
82 82
 			$sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
83
-    		$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
84
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85
-    		$sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'";
86
-    		$sql.= " AND c.entity = ".$conf->entity;
87
-    		$sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
88
-            if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
89
-            if (!$user->rights->societe->client->voir  && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
90
-    		$sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid";
91
-    		$sql.= " ORDER BY date_line ASC";
92
-    		$sql.= $db->plimit($max, 0);
83
+			$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
84
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85
+			$sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'";
86
+			$sql.= " AND c.entity = ".$conf->entity;
87
+			$sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
88
+			if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
89
+			if (!$user->rights->societe->client->voir  && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
90
+			$sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid";
91
+			$sql.= " ORDER BY date_line ASC";
92
+			$sql.= $db->plimit($max, 0);
93 93
 
94
-    		$resql = $db->query($sql);
95
-    		if ($resql)
96
-    		{
97
-    			$num = $db->num_rows($resql);
94
+			$resql = $db->query($sql);
95
+			if ($resql)
96
+			{
97
+				$num = $db->num_rows($resql);
98 98
 
99
-    			$i = 0;
99
+				$i = 0;
100 100
 
101
-    			$thirdpartytmp = new Societe($this->db);
101
+				$thirdpartytmp = new Societe($this->db);
102 102
 
103
-    			while ($i < $num)
104
-    			{
105
-    			    $late='';
103
+				while ($i < $num)
104
+				{
105
+					$late='';
106 106
 
107
-    				$objp = $db->fetch_object($resql);
107
+					$objp = $db->fetch_object($resql);
108 108
 
109 109
 					$dateline=$db->jdate($objp->date_line);
110 110
 					if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late"));
111 111
 
112
-    				$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
113
-    				'logo' => $this->boximg,
114
-    				'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
112
+					$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
113
+					'logo' => $this->boximg,
114
+					'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
115 115
 
116
-    				$this->info_box_contents[$i][1] = array('td' => '',
117
-    				'text' => ($objp->ref?$objp->ref:$objp->rowid),	// Some contracts have no ref
118
-    				'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
116
+					$this->info_box_contents[$i][1] = array('td' => '',
117
+					'text' => ($objp->ref?$objp->ref:$objp->rowid),	// Some contracts have no ref
118
+					'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
119 119
 
120
-    				$thirdpartytmp->id = $objp->socid;
121
-    				$thirdpartytmp->name = $objp->name;
120
+					$thirdpartytmp->id = $objp->socid;
121
+					$thirdpartytmp->name = $objp->name;
122 122
 
123
-    				$this->info_box_contents[$i][2] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone" align="left"',
124
-    				'text' => $thirdpartytmp->getNomUrl(1, 'customer'),
125
-    				'asis' => 1
126
-    				);
123
+					$this->info_box_contents[$i][2] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone" align="left"',
124
+					'text' => $thirdpartytmp->getNomUrl(1, 'customer'),
125
+					'asis' => 1
126
+					);
127 127
 
128
-    				$this->info_box_contents[$i][4] = array('td' => 'align="center"',
129
-    				'text' => dol_print_date($dateline,'day'),
130
-    				'text2'=> $late);
128
+					$this->info_box_contents[$i][4] = array('td' => 'align="center"',
129
+					'text' => dol_print_date($dateline,'day'),
130
+					'text2'=> $late);
131 131
 
132
-    				$this->info_box_contents[$i][5] = array('td' => 'class="right"',
133
-    				'text' => $objp->nb_services);
132
+					$this->info_box_contents[$i][5] = array('td' => 'class="right"',
133
+					'text' => $objp->nb_services);
134 134
 
135 135
 
136
-    				$i++;
137
-    			}
136
+					$i++;
137
+				}
138 138
 
139
-    			if ($num==0)
140
-    			{
141
-    			    $langs->load("contracts");
142
-    			    $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoExpiredServices"));
143
-    			}
139
+				if ($num==0)
140
+				{
141
+					$langs->load("contracts");
142
+					$this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoExpiredServices"));
143
+				}
144 144
 
145 145
 				$db->free($resql);
146
-    		}
147
-    		else
148
-    		{
149
-    			$this->info_box_contents[0][0] = array(  'td' => '',
150
-                                                        'maxlength'=>500,
151
-                                                        'text' => ($db->error().' sql='.$sql));
152
-    		}
153
-
154
-
155
-    	}
156
-    	else
157
-    	{
158
-    		$this->info_box_contents[0][0] = array(
159
-    		    'td' => 'align="left" class="nohover opacitymedium"',
160
-    		    'text' => $langs->trans("ReadPermissionNotAllowed")
161
-    		);
162
-    	}
163
-    }
146
+			}
147
+			else
148
+			{
149
+				$this->info_box_contents[0][0] = array(  'td' => '',
150
+														'maxlength'=>500,
151
+														'text' => ($db->error().' sql='.$sql));
152
+			}
153
+
154
+
155
+		}
156
+		else
157
+		{
158
+			$this->info_box_contents[0][0] = array(
159
+				'td' => 'align="left" class="nohover opacitymedium"',
160
+				'text' => $langs->trans("ReadPermissionNotAllowed")
161
+			);
162
+		}
163
+	}
164 164
 
165 165
 	/**
166 166
 	 *	Method to show box
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 	 *  @param	int		$nooutput	No print, only return string
171 171
 	 *	@return	string
172 172
 	 */
173
-    function showBox($head = null, $contents = null, $nooutput=0)
174
-    {
175
-        return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
176
-    }
173
+	function showBox($head = null, $contents = null, $nooutput=0)
174
+	{
175
+		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
176
+	}
177 177
 
178 178
  }
179 179
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 class box_services_expired extends ModeleBoxes
31 31
 {
32 32
 
33
-    var $boxcode="expiredservices";     // id of box
34
-    var $boximg="object_contract";
35
-    var $boxlabel="BoxOldestExpiredServices";
36
-    var $depends = array("contrat");	// conf->propal->enabled
33
+    var $boxcode = "expiredservices"; // id of box
34
+    var $boximg = "object_contract";
35
+    var $boxlabel = "BoxOldestExpiredServices";
36
+    var $depends = array("contrat"); // conf->propal->enabled
37 37
 
38 38
     var $db;
39 39
     var $param;
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
      *  @param  DoliDB  $db         Database handler
49 49
      *  @param  string  $param      More parameters
50 50
      */
51
-    function __construct($db,$param)
51
+    function __construct($db, $param)
52 52
     {
53 53
         global $user;
54 54
 
55
-        $this->db=$db;
55
+        $this->db = $db;
56 56
 
57
-        $this->hidden=! ($user->rights->contrat->lire);
57
+        $this->hidden = !($user->rights->contrat->lire);
58 58
     }
59 59
 
60 60
     /**
@@ -63,33 +63,33 @@  discard block
 block discarded – undo
63 63
      *  @param	int		$max        Maximum number of records to load
64 64
      *  @return	void
65 65
      */
66
-    function loadBox($max=5)
66
+    function loadBox($max = 5)
67 67
     {
68 68
     	global $user, $langs, $db, $conf;
69 69
 
70
-    	$this->max=$max;
70
+    	$this->max = $max;
71 71
 
72
-    	$now=dol_now();
72
+    	$now = dol_now();
73 73
 
74
-    	$this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices",$max));
74
+    	$this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max));
75 75
 
76 76
     	if ($user->rights->contrat->lire)
77 77
     	{
78 78
     	    // Select contracts with at least one expired service
79 79
 			$sql = "SELECT ";
80
-    		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat,";
81
-			$sql.= " s.nom as name, s.rowid as socid,";
82
-			$sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
83
-    		$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
84
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85
-    		$sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'";
86
-    		$sql.= " AND c.entity = ".$conf->entity;
87
-    		$sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
88
-            if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
89
-            if (!$user->rights->societe->client->voir  && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
90
-    		$sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid";
91
-    		$sql.= " ORDER BY date_line ASC";
92
-    		$sql.= $db->plimit($max, 0);
80
+    		$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat,";
81
+			$sql .= " s.nom as name, s.rowid as socid,";
82
+			$sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
83
+    		$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
84
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85
+    		$sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'";
86
+    		$sql .= " AND c.entity = ".$conf->entity;
87
+    		$sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
88
+            if ($user->societe_id) $sql .= ' AND c.fk_soc = '.$user->societe_id;
89
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
90
+    		$sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid";
91
+    		$sql .= " ORDER BY date_line ASC";
92
+    		$sql .= $db->plimit($max, 0);
93 93
 
94 94
     		$resql = $db->query($sql);
95 95
     		if ($resql)
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 
103 103
     			while ($i < $num)
104 104
     			{
105
-    			    $late='';
105
+    			    $late = '';
106 106
 
107 107
     				$objp = $db->fetch_object($resql);
108 108
 
109
-					$dateline=$db->jdate($objp->date_line);
110
-					if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late"));
109
+					$dateline = $db->jdate($objp->date_line);
110
+					if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
111 111
 
112 112
     				$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
113 113
     				'logo' => $this->boximg,
114 114
     				'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
115 115
 
116 116
     				$this->info_box_contents[$i][1] = array('td' => '',
117
-    				'text' => ($objp->ref?$objp->ref:$objp->rowid),	// Some contracts have no ref
117
+    				'text' => ($objp->ref ? $objp->ref : $objp->rowid), // Some contracts have no ref
118 118
     				'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
119 119
 
120 120
     				$thirdpartytmp->id = $objp->socid;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     				);
127 127
 
128 128
     				$this->info_box_contents[$i][4] = array('td' => 'align="center"',
129
-    				'text' => dol_print_date($dateline,'day'),
129
+    				'text' => dol_print_date($dateline, 'day'),
130 130
     				'text2'=> $late);
131 131
 
132 132
     				$this->info_box_contents[$i][5] = array('td' => 'class="right"',
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
     				$i++;
137 137
     			}
138 138
 
139
-    			if ($num==0)
139
+    			if ($num == 0)
140 140
     			{
141 141
     			    $langs->load("contracts");
142
-    			    $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoExpiredServices"));
142
+    			    $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoExpiredServices"));
143 143
     			}
144 144
 
145 145
 				$db->free($resql);
146 146
     		}
147 147
     		else
148 148
     		{
149
-    			$this->info_box_contents[0][0] = array(  'td' => '',
149
+    			$this->info_box_contents[0][0] = array('td' => '',
150 150
                                                         'maxlength'=>500,
151 151
                                                         'text' => ($db->error().' sql='.$sql));
152 152
     		}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 *  @param	int		$nooutput	No print, only return string
171 171
 	 *	@return	string
172 172
 	 */
173
-    function showBox($head = null, $contents = null, $nooutput=0)
173
+    function showBox($head = null, $contents = null, $nooutput = 0)
174 174
     {
175 175
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
176 176
     }
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -81,12 +81,18 @@  discard block
 block discarded – undo
81 81
 			$sql.= " s.nom as name, s.rowid as socid,";
82 82
 			$sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
83 83
     		$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
84
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
84
+            if (!$user->rights->societe->client->voir && !$user->societe_id) {
85
+            	$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
86
+            }
85 87
     		$sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'";
86 88
     		$sql.= " AND c.entity = ".$conf->entity;
87 89
     		$sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
88
-            if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
89
-            if (!$user->rights->societe->client->voir  && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
90
+            if ($user->societe_id) {
91
+            	$sql.=' AND c.fk_soc = '.$user->societe_id;
92
+            }
93
+            if (!$user->rights->societe->client->voir  && !$user->societe_id) {
94
+            	$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
+            }
90 96
     		$sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid";
91 97
     		$sql.= " ORDER BY date_line ASC";
92 98
     		$sql.= $db->plimit($max, 0);
@@ -107,7 +113,9 @@  discard block
 block discarded – undo
107 113
     				$objp = $db->fetch_object($resql);
108 114
 
109 115
 					$dateline=$db->jdate($objp->date_line);
110
-					if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late"));
116
+					if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) {
117
+						$late=img_warning($langs->trans("Late"));
118
+					}
111 119
 
112 120
     				$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
113 121
     				'logo' => $this->boximg,
@@ -143,8 +151,7 @@  discard block
 block discarded – undo
143 151
     			}
144 152
 
145 153
 				$db->free($resql);
146
-    		}
147
-    		else
154
+    		} else
148 155
     		{
149 156
     			$this->info_box_contents[0][0] = array(  'td' => '',
150 157
                                                         'maxlength'=>500,
@@ -152,8 +159,7 @@  discard block
 block discarded – undo
152 159
     		}
153 160
 
154 161
 
155
-    	}
156
-    	else
162
+    	} else
157 163
     	{
158 164
     		$this->info_box_contents[0][0] = array(
159 165
     		    'td' => 'align="left" class="nohover opacitymedium"',
Please login to merge, or discard this patch.
htdocs/core/boxes/box_graph_orders_supplier_permonth.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *  Load data into info_box_contents array to show array later.
59 59
 	 *
60 60
 	 *  @param	int		$max        Maximum number of records to load
61
-     *  @return	void
61
+	 *  @return	void
62 62
 	 */
63 63
 	function loadBox($max=5)
64 64
 	{
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 
91 91
 		if ($user->rights->fournisseur->commande->lire)
92 92
 		{
93
-		    $langs->load("orders");
93
+			$langs->load("orders");
94 94
 
95
-		    $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
95
+			$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
96 96
 			$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
97 97
 			$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
98 98
 
@@ -248,15 +248,15 @@  discard block
 block discarded – undo
248 248
 			else
249 249
 			{
250 250
 				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
251
-    	        										'maxlength'=>500,
252
-	            										'text' => $mesg);
251
+														'maxlength'=>500,
252
+														'text' => $mesg);
253 253
 			}
254 254
 
255 255
 		}
256 256
 		else {
257 257
 			$this->info_box_contents[0][0] = array(
258
-			    'td' => 'align="left" class="nohover opacitymedium"',
259
-                'text' => $langs->trans("ReadPermissionNotAllowed")
258
+				'td' => 'align="left" class="nohover opacitymedium"',
259
+				'text' => $langs->trans("ReadPermissionNotAllowed")
260 260
 			);
261 261
 		}
262 262
 	}
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 *  @param	int		$nooutput	No print, only return string
270 270
 	 *	@return	string
271 271
 	 */
272
-    function showBox($head = null, $contents = null, $nooutput=0)
273
-    {
272
+	function showBox($head = null, $contents = null, $nooutput=0)
273
+	{
274 274
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
275 275
 	}
276 276
 
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class box_graph_orders_supplier_permonth extends ModeleBoxes
30 30
 {
31
-	var $boxcode="orderssupplierpermonth";
32
-	var $boximg="object_order";
33
-	var $boxlabel="BoxSuppliersOrdersPerMonth";
31
+	var $boxcode = "orderssupplierpermonth";
32
+	var $boximg = "object_order";
33
+	var $boxlabel = "BoxSuppliersOrdersPerMonth";
34 34
 	var $depends = array("fournisseur");
35 35
 
36 36
 	var $db;
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	 * 	@param	DoliDB	$db			Database handler
46 46
 	 *  @param	string	$param		More parameters
47 47
 	 */
48
-	function __construct($db,$param)
48
+	function __construct($db, $param)
49 49
 	{
50 50
 		global $user;
51 51
 
52
-		$this->db=$db;
52
+		$this->db = $db;
53 53
 
54
-		$this->hidden = ! ($user->rights->fournisseur->commande->lire);
54
+		$this->hidden = !($user->rights->fournisseur->commande->lire);
55 55
 	}
56 56
 
57 57
 	/**
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
 	 *  @param	int		$max        Maximum number of records to load
61 61
      *  @return	void
62 62
 	 */
63
-	function loadBox($max=5)
63
+	function loadBox($max = 5)
64 64
 	{
65 65
 		global $conf, $user, $langs, $db;
66 66
 
67
-		$this->max=$max;
67
+		$this->max = $max;
68 68
 
69
-		$refreshaction='refresh_'.$this->boxcode;
69
+		$refreshaction = 'refresh_'.$this->boxcode;
70 70
 
71 71
 		include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
72 72
 
73
-		$text = $langs->trans("BoxSuppliersOrdersPerMonth",$max);
73
+		$text = $langs->trans("BoxSuppliersOrdersPerMonth", $max);
74 74
 		$this->info_box_head = array(
75 75
 				'text' => $text,
76 76
 				'limit'=> dol_strlen($text),
@@ -82,50 +82,50 @@  discard block
 block discarded – undo
82 82
 				'target'=>'none'	// Set '' to get target="_blank"
83 83
 		);
84 84
 
85
-		$dir=''; 	// We don't need a path because image file will not be saved into disk
86
-		$prefix='';
87
-		$socid=0;
88
-		if ($user->societe_id) $socid=$user->societe_id;
89
-		if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-';	// If user has no permission to see all, output dir is specific to user
85
+		$dir = ''; // We don't need a path because image file will not be saved into disk
86
+		$prefix = '';
87
+		$socid = 0;
88
+		if ($user->societe_id) $socid = $user->societe_id;
89
+		if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
90 90
 
91 91
 		if ($user->rights->fournisseur->commande->lire)
92 92
 		{
93 93
 		    $langs->load("orders");
94 94
 
95
-		    $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
96
-			$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
97
-			$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
95
+		    $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
96
+			$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
97
+			$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
98 98
 
99 99
 			include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
100 100
 			include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
101
-			$autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
102
-			if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
101
+			$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
102
+			if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
103 103
 			{
104
-				$endyear=GETPOST($param_year,'int');
105
-				$shownb=GETPOST($param_shownb,'alpha');
106
-				$showtot=GETPOST($param_showtot,'alpha');
104
+				$endyear = GETPOST($param_year, 'int');
105
+				$shownb = GETPOST($param_shownb, 'alpha');
106
+				$showtot = GETPOST($param_showtot, 'alpha');
107 107
 			}
108 108
 			else
109 109
 			{
110
-				$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
111
-				$endyear=$tmparray['year'];
112
-				$shownb=$tmparray['shownb'];
113
-				$showtot=$tmparray['showtot'];
110
+				$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
111
+				$endyear = $tmparray['year'];
112
+				$shownb = $tmparray['shownb'];
113
+				$showtot = $tmparray['showtot'];
114 114
 			}
115
-			if (empty($shownb) && empty($showtot)) $showtot=1;
116
-			$nowarray=dol_getdate(dol_now(),true);
117
-			if (empty($endyear)) $endyear=$nowarray['year'];
118
-			$startyear=$endyear-1;
119
-			$mode='supplier';
120
-			$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
121
-			$HEIGHT='192';
115
+			if (empty($shownb) && empty($showtot)) $showtot = 1;
116
+			$nowarray = dol_getdate(dol_now(), true);
117
+			if (empty($endyear)) $endyear = $nowarray['year'];
118
+			$startyear = $endyear - 1;
119
+			$mode = 'supplier';
120
+			$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
121
+			$HEIGHT = '192';
122 122
 
123 123
 			$stats = new CommandeStats($this->db, $socid, $mode, 0);
124 124
 
125 125
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
126 126
 			if ($shownb)
127 127
 			{
128
-				$data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
128
+				$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
129 129
 
130 130
 				$filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
131 131
 				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 
134 134
 				$px1 = new DolGraph();
135 135
 				$mesg = $px1->isGraphKo();
136
-				if (! $mesg)
136
+				if (!$mesg)
137 137
 				{
138 138
 					$px1->SetData($data1);
139 139
 					unset($data1);
140 140
 					$px1->SetPrecisionY(0);
141
-					$i=$startyear;$legend=array();
141
+					$i = $startyear; $legend = array();
142 142
 					while ($i <= $endyear)
143 143
 					{
144
-						$legend[]=$i;
144
+						$legend[] = $i;
145 145
 						$i++;
146 146
 					}
147 147
 					$px1->SetLegend($legend);
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 					$px1->SetHorizTickIncrement(1);
154 154
 					$px1->SetPrecisionY(0);
155 155
 					$px1->SetCssPrefix("cssboxes");
156
-					$px1->mode='depth';
156
+					$px1->mode = 'depth';
157 157
 					$px1->SetTitle($langs->trans("NumberOfOrdersByMonth"));
158 158
 
159
-					$px1->draw($filenamenb,$fileurlnb);
159
+					$px1->draw($filenamenb, $fileurlnb);
160 160
 				}
161 161
 			}
162 162
 
163 163
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
164 164
 			if ($showtot)
165 165
 			{
166
-				$data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
166
+				$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
167 167
 
168 168
 				$filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
169 169
 				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
 
172 172
 				$px2 = new DolGraph();
173 173
 				$mesg = $px2->isGraphKo();
174
-				if (! $mesg)
174
+				if (!$mesg)
175 175
 				{
176 176
 					$px2->SetData($data2);
177 177
 					unset($data2);
178 178
 					$px2->SetPrecisionY(0);
179
-					$i=$startyear;$legend=array();
179
+					$i = $startyear; $legend = array();
180 180
 					while ($i <= $endyear)
181 181
 					{
182
-						$legend[]=$i;
182
+						$legend[] = $i;
183 183
 						$i++;
184 184
 					}
185 185
 					$px2->SetLegend($legend);
@@ -191,63 +191,63 @@  discard block
 block discarded – undo
191 191
 					$px2->SetHorizTickIncrement(1);
192 192
 					$px2->SetPrecisionY(0);
193 193
 					$px2->SetCssPrefix("cssboxes");
194
-					$px2->mode='depth';
194
+					$px2->mode = 'depth';
195 195
 					$px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
196 196
 
197
-					$px2->draw($filenamenb,$fileurlnb);
197
+					$px2->draw($filenamenb, $fileurlnb);
198 198
 				}
199 199
 			}
200 200
 
201 201
 			if (empty($conf->use_javascript_ajax))
202 202
 			{
203 203
 				$langs->load("errors");
204
-				$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
204
+				$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
205 205
 			}
206 206
 
207
-			if (! $mesg)
207
+			if (!$mesg)
208 208
 			{
209
-				$stringtoshow='';
210
-				$stringtoshow.='<script type="text/javascript" language="javascript">
209
+				$stringtoshow = '';
210
+				$stringtoshow .= '<script type="text/javascript" language="javascript">
211 211
 					jQuery(document).ready(function() {
212 212
 						jQuery("#idsubimg'.$this->boxcode.'").click(function() {
213 213
 							jQuery("#idfilter'.$this->boxcode.'").toggle();
214 214
 						});
215 215
 					});
216 216
 					</script>';
217
-				$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
218
-				$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
219
-				$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
220
-				$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
221
-				$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfOrdersByMonth");
222
-				$stringtoshow.=' &nbsp; ';
223
-				$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfOrdersByMonthHT");
224
-				$stringtoshow.='<br>';
225
-				$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
226
-				$stringtoshow.='<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"),'refresh.png','','',1).'">';
227
-				$stringtoshow.='</form>';
228
-				$stringtoshow.='</div>';
217
+				$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
218
+				$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
219
+				$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
220
+				$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
221
+				$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfOrdersByMonth");
222
+				$stringtoshow .= ' &nbsp; ';
223
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfOrdersByMonthHT");
224
+				$stringtoshow .= '<br>';
225
+				$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
226
+				$stringtoshow .= '<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
227
+				$stringtoshow .= '</form>';
228
+				$stringtoshow .= '</div>';
229 229
 				if ($shownb && $showtot)
230 230
 				{
231
-					$stringtoshow.='<div class="fichecenter">';
232
-					$stringtoshow.='<div class="fichehalfleft">';
231
+					$stringtoshow .= '<div class="fichecenter">';
232
+					$stringtoshow .= '<div class="fichehalfleft">';
233 233
 				}
234
-				if ($shownb) $stringtoshow.=$px1->show();
234
+				if ($shownb) $stringtoshow .= $px1->show();
235 235
 				if ($shownb && $showtot)
236 236
 				{
237
-					$stringtoshow.='</div>';
238
-					$stringtoshow.='<div class="fichehalfright">';
237
+					$stringtoshow .= '</div>';
238
+					$stringtoshow .= '<div class="fichehalfright">';
239 239
 				}
240
-				if ($showtot) $stringtoshow.=$px2->show();
240
+				if ($showtot) $stringtoshow .= $px2->show();
241 241
 				if ($shownb && $showtot)
242 242
 				{
243
-					$stringtoshow.='</div>';
244
-					$stringtoshow.='</div>';
243
+					$stringtoshow .= '</div>';
244
+					$stringtoshow .= '</div>';
245 245
 				}
246
-				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
246
+				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"', 'textnoformat'=>$stringtoshow);
247 247
 			}
248 248
 			else
249 249
 			{
250
-				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
250
+				$this->info_box_contents[0][0] = array('td' => 'align="left" class="nohover"',
251 251
     	        										'maxlength'=>500,
252 252
 	            										'text' => $mesg);
253 253
 			}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *  @param	int		$nooutput	No print, only return string
270 270
 	 *	@return	string
271 271
 	 */
272
-    function showBox($head = null, $contents = null, $nooutput=0)
272
+    function showBox($head = null, $contents = null, $nooutput = 0)
273 273
     {
274 274
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
275 275
 	}
Please login to merge, or discard this patch.
Braces   +34 added lines, -16 removed lines patch added patch discarded remove patch
@@ -85,8 +85,13 @@  discard block
 block discarded – undo
85 85
 		$dir=''; 	// We don't need a path because image file will not be saved into disk
86 86
 		$prefix='';
87 87
 		$socid=0;
88
-		if ($user->societe_id) $socid=$user->societe_id;
89
-		if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-';	// If user has no permission to see all, output dir is specific to user
88
+		if ($user->societe_id) {
89
+			$socid=$user->societe_id;
90
+		}
91
+		if (! $user->rights->societe->client->voir || $socid) {
92
+			$prefix.='private-'.$user->id.'-';
93
+		}
94
+		// If user has no permission to see all, output dir is specific to user
90 95
 
91 96
 		if ($user->rights->fournisseur->commande->lire)
92 97
 		{
@@ -104,17 +109,20 @@  discard block
 block discarded – undo
104 109
 				$endyear=GETPOST($param_year,'int');
105 110
 				$shownb=GETPOST($param_shownb,'alpha');
106 111
 				$showtot=GETPOST($param_showtot,'alpha');
107
-			}
108
-			else
112
+			} else
109 113
 			{
110 114
 				$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
111 115
 				$endyear=$tmparray['year'];
112 116
 				$shownb=$tmparray['shownb'];
113 117
 				$showtot=$tmparray['showtot'];
114 118
 			}
115
-			if (empty($shownb) && empty($showtot)) $showtot=1;
119
+			if (empty($shownb) && empty($showtot)) {
120
+				$showtot=1;
121
+			}
116 122
 			$nowarray=dol_getdate(dol_now(),true);
117
-			if (empty($endyear)) $endyear=$nowarray['year'];
123
+			if (empty($endyear)) {
124
+				$endyear=$nowarray['year'];
125
+			}
118 126
 			$startyear=$endyear-1;
119 127
 			$mode='supplier';
120 128
 			$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
@@ -128,8 +136,12 @@  discard block
 block discarded – undo
128 136
 				$data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
129 137
 
130 138
 				$filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
131
-				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
132
-				if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssuppliernbinyear-'.$endyear.'.png';
139
+				if ($mode == 'customer') {
140
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
141
+				}
142
+				if ($mode == 'supplier') {
143
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssuppliernbinyear-'.$endyear.'.png';
144
+				}
133 145
 
134 146
 				$px1 = new DolGraph();
135 147
 				$mesg = $px1->isGraphKo();
@@ -166,8 +178,12 @@  discard block
 block discarded – undo
166 178
 				$data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
167 179
 
168 180
 				$filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
169
-				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
170
-				if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssupplieramountinyear-'.$endyear.'.png';
181
+				if ($mode == 'customer') {
182
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
183
+				}
184
+				if ($mode == 'supplier') {
185
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssupplieramountinyear-'.$endyear.'.png';
186
+				}
171 187
 
172 188
 				$px2 = new DolGraph();
173 189
 				$mesg = $px2->isGraphKo();
@@ -231,29 +247,31 @@  discard block
 block discarded – undo
231 247
 					$stringtoshow.='<div class="fichecenter">';
232 248
 					$stringtoshow.='<div class="fichehalfleft">';
233 249
 				}
234
-				if ($shownb) $stringtoshow.=$px1->show();
250
+				if ($shownb) {
251
+					$stringtoshow.=$px1->show();
252
+				}
235 253
 				if ($shownb && $showtot)
236 254
 				{
237 255
 					$stringtoshow.='</div>';
238 256
 					$stringtoshow.='<div class="fichehalfright">';
239 257
 				}
240
-				if ($showtot) $stringtoshow.=$px2->show();
258
+				if ($showtot) {
259
+					$stringtoshow.=$px2->show();
260
+				}
241 261
 				if ($shownb && $showtot)
242 262
 				{
243 263
 					$stringtoshow.='</div>';
244 264
 					$stringtoshow.='</div>';
245 265
 				}
246 266
 				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
247
-			}
248
-			else
267
+			} else
249 268
 			{
250 269
 				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
251 270
     	        										'maxlength'=>500,
252 271
 	            										'text' => $mesg);
253 272
 			}
254 273
 
255
-		}
256
-		else {
274
+		} else {
257 275
 			$this->info_box_contents[0][0] = array(
258 276
 			    'td' => 'align="left" class="nohover opacitymedium"',
259 277
                 'text' => $langs->trans("ReadPermissionNotAllowed")
Please login to merge, or discard this patch.
htdocs/core/boxes/box_factures_imp.php 3 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function __construct($db,$param)
55 55
 	{
56
-	    global $user;
56
+		global $user;
57 57
 
58
-	    $this->db=$db;
58
+		$this->db=$db;
59 59
 
60
-	    $this->hidden=! ($user->rights->facture->lire);
60
+		$this->hidden=! ($user->rights->facture->lire);
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 *  Load data into info_box_contents array to show array later.
65 65
 	 *
66 66
 	 *  @param	int		$max        Maximum number of records to load
67
-     *  @return	void
67
+	 *  @return	void
68 68
 	 */
69 69
 	function loadBox($max=5)
70 70
 	{
@@ -73,24 +73,24 @@  discard block
 block discarded – undo
73 73
 		$this->max=$max;
74 74
 
75 75
 		include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
76
-        include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
76
+		include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
77 77
 
78
-        $facturestatic = new Facture($db);
79
-        $societestatic = new Societe($db);
78
+		$facturestatic = new Facture($db);
79
+		$societestatic = new Societe($db);
80 80
 
81 81
 		$this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills",$max));
82 82
 
83 83
 		if ($user->rights->facture->lire)
84 84
 		{
85 85
 			$sql = "SELECT s.nom as name, s.rowid as socid,";
86
-            $sql.= " s.code_client,";
87
-            $sql.= " s.logo,";
86
+			$sql.= " s.code_client,";
87
+			$sql.= " s.logo,";
88 88
 			$sql.= " f.facnumber, f.date_lim_reglement as datelimite,";
89
-            $sql.= " f.type,";
89
+			$sql.= " f.type,";
90 90
 			$sql.= " f.amount, f.datef as df,";
91
-            $sql.= " f.total as total_ht,";
92
-            $sql.= " f.tva as total_tva,";
93
-            $sql.= " f.total_ttc,";
91
+			$sql.= " f.total as total_ht,";
92
+			$sql.= " f.tva as total_tva,";
93
+			$sql.= " f.total_ttc,";
94 94
 			$sql.= " f.paye, f.fk_statut, f.rowid as facid";
95 95
 			$sql.= ", sum(pf.amount) as am";
96 96
 			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
@@ -122,52 +122,52 @@  discard block
 block discarded – undo
122 122
 				{
123 123
 					$objp = $db->fetch_object($result);
124 124
 					$datelimite=$db->jdate($objp->datelimite);
125
-                    $facturestatic->id = $objp->facid;
126
-                    $facturestatic->ref = $objp->facnumber;
127
-                    $facturestatic->type = $objp->type;
128
-                    $facturestatic->total_ht = $objp->total_ht;
129
-                    $facturestatic->total_tva = $objp->total_tva;
130
-                    $facturestatic->total_ttc = $objp->total_ttc;
125
+					$facturestatic->id = $objp->facid;
126
+					$facturestatic->ref = $objp->facnumber;
127
+					$facturestatic->type = $objp->type;
128
+					$facturestatic->total_ht = $objp->total_ht;
129
+					$facturestatic->total_tva = $objp->total_tva;
130
+					$facturestatic->total_ttc = $objp->total_ttc;
131 131
 					$facturestatic->statut = $objp->fk_statut;
132 132
 					$facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
133
-                    $societestatic->id = $objp->socid;
134
-                    $societestatic->name = $objp->name;
135
-                    $societestatic->client = 1;
136
-                    $societestatic->code_client = $objp->code_client;
137
-                    $societestatic->logo = $objp->logo;
133
+					$societestatic->id = $objp->socid;
134
+					$societestatic->name = $objp->name;
135
+					$societestatic->client = 1;
136
+					$societestatic->code_client = $objp->code_client;
137
+					$societestatic->logo = $objp->logo;
138 138
 
139 139
 					$late='';
140 140
 					if ($facturestatic->hasDelay()) {
141 141
 						$late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));
142 142
 					}
143 143
 
144
-                    $this->info_box_contents[$line][] = array(
145
-                        'td' => '',
146
-                        'text' => $facturestatic->getNomUrl(1),
147
-                        'text2'=> $late,
148
-                        'asis' => 1,
149
-                    );
150
-
151
-                    $this->info_box_contents[$line][] = array(
152
-                        'td' => '',
153
-                        'text' => $societestatic->getNomUrl(1, '', 44),
154
-                        'asis' => 1,
155
-                    );
156
-
157
-                    $this->info_box_contents[$line][] = array(
158
-                        'td' => 'class="right"',
159
-                        'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
160
-                    );
161
-
162
-                    $this->info_box_contents[$line][] = array(
163
-                        'td' => 'class="right"',
164
-                        'text' => dol_print_date($datelimite,'day'),
165
-                    );
166
-
167
-                    $this->info_box_contents[$line][] = array(
168
-                        'td' => 'align="right" width="18"',
169
-                        'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$objp->am),
170
-                    );
144
+					$this->info_box_contents[$line][] = array(
145
+						'td' => '',
146
+						'text' => $facturestatic->getNomUrl(1),
147
+						'text2'=> $late,
148
+						'asis' => 1,
149
+					);
150
+
151
+					$this->info_box_contents[$line][] = array(
152
+						'td' => '',
153
+						'text' => $societestatic->getNomUrl(1, '', 44),
154
+						'asis' => 1,
155
+					);
156
+
157
+					$this->info_box_contents[$line][] = array(
158
+						'td' => 'class="right"',
159
+						'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
160
+					);
161
+
162
+					$this->info_box_contents[$line][] = array(
163
+						'td' => 'class="right"',
164
+						'text' => dol_print_date($datelimite,'day'),
165
+					);
166
+
167
+					$this->info_box_contents[$line][] = array(
168
+						'td' => 'align="right" width="18"',
169
+						'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$objp->am),
170
+					);
171 171
 
172 172
 					$line++;
173 173
 				}
@@ -178,18 +178,18 @@  discard block
 block discarded – undo
178 178
 			}
179 179
 			else
180 180
 			{
181
-                $this->info_box_contents[0][0] = array(
182
-                    'td' => '',
183
-                    'maxlength'=>500,
184
-                    'text' => ($db->error().' sql='.$sql),
185
-                );
181
+				$this->info_box_contents[0][0] = array(
182
+					'td' => '',
183
+					'maxlength'=>500,
184
+					'text' => ($db->error().' sql='.$sql),
185
+				);
186 186
 			}
187 187
 		}
188 188
 		else {
189
-            $this->info_box_contents[0][0] = array(
190
-                'td' => 'align="left" class="nohover opacitymedium"',
191
-                'text' => $langs->trans("ReadPermissionNotAllowed")
192
-            );
189
+			$this->info_box_contents[0][0] = array(
190
+				'td' => 'align="left" class="nohover opacitymedium"',
191
+				'text' => $langs->trans("ReadPermissionNotAllowed")
192
+			);
193 193
 		}
194 194
 	}
195 195
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	 *  @param	int		$nooutput	No print, only return string
202 202
 	 *	@return	string
203 203
 	 */
204
-    function showBox($head = null, $contents = null, $nooutput=0)
205
-    {
204
+	function showBox($head = null, $contents = null, $nooutput=0)
205
+	{
206 206
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
207 207
 	}
208 208
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class box_factures_imp extends ModeleBoxes
35 35
 {
36
-	var $boxcode="oldestunpaidcustomerbills";
37
-	var $boximg="object_bill";
38
-	var $boxlabel="BoxOldestUnpaidCustomerBills";
36
+	var $boxcode = "oldestunpaidcustomerbills";
37
+	var $boximg = "object_bill";
38
+	var $boxlabel = "BoxOldestUnpaidCustomerBills";
39 39
 	var $depends = array("facture");
40 40
 
41 41
 	var $db;
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	 *  @param  DoliDB  $db         Database handler
52 52
 	 *  @param  string  $param      More parameters
53 53
 	 */
54
-	function __construct($db,$param)
54
+	function __construct($db, $param)
55 55
 	{
56 56
 	    global $user;
57 57
 
58
-	    $this->db=$db;
58
+	    $this->db = $db;
59 59
 
60
-	    $this->hidden=! ($user->rights->facture->lire);
60
+	    $this->hidden = !($user->rights->facture->lire);
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	 *  @param	int		$max        Maximum number of records to load
67 67
      *  @return	void
68 68
 	 */
69
-	function loadBox($max=5)
69
+	function loadBox($max = 5)
70 70
 	{
71 71
 		global $conf, $user, $langs, $db;
72 72
 
73
-		$this->max=$max;
73
+		$this->max = $max;
74 74
 
75 75
 		include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
76 76
         include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
         $facturestatic = new Facture($db);
79 79
         $societestatic = new Societe($db);
80 80
 
81
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills",$max));
81
+		$this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max));
82 82
 
83 83
 		if ($user->rights->facture->lire)
84 84
 		{
85 85
 			$sql = "SELECT s.nom as name, s.rowid as socid,";
86
-            $sql.= " s.code_client,";
87
-            $sql.= " s.logo,";
88
-			$sql.= " f.facnumber, f.date_lim_reglement as datelimite,";
89
-            $sql.= " f.type,";
90
-			$sql.= " f.amount, f.datef as df,";
91
-            $sql.= " f.total as total_ht,";
92
-            $sql.= " f.tva as total_tva,";
93
-            $sql.= " f.total_ttc,";
94
-			$sql.= " f.paye, f.fk_statut, f.rowid as facid";
95
-			$sql.= ", sum(pf.amount) as am";
96
-			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
97
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
98
-			$sql.= ", ".MAIN_DB_PREFIX."facture as f";
99
-			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
100
-			$sql.= " WHERE f.fk_soc = s.rowid";
101
-			$sql.= " AND f.entity = ".$conf->entity;
102
-			$sql.= " AND f.paye = 0";
103
-			$sql.= " AND fk_statut = 1";
104
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
105
-			if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
106
-			$sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.facnumber, f.date_lim_reglement,";
107
-			$sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
86
+            $sql .= " s.code_client,";
87
+            $sql .= " s.logo,";
88
+			$sql .= " f.facnumber, f.date_lim_reglement as datelimite,";
89
+            $sql .= " f.type,";
90
+			$sql .= " f.amount, f.datef as df,";
91
+            $sql .= " f.total as total_ht,";
92
+            $sql .= " f.tva as total_tva,";
93
+            $sql .= " f.total_ttc,";
94
+			$sql .= " f.paye, f.fk_statut, f.rowid as facid";
95
+			$sql .= ", sum(pf.amount) as am";
96
+			$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
97
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
98
+			$sql .= ", ".MAIN_DB_PREFIX."facture as f";
99
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
100
+			$sql .= " WHERE f.fk_soc = s.rowid";
101
+			$sql .= " AND f.entity = ".$conf->entity;
102
+			$sql .= " AND f.paye = 0";
103
+			$sql .= " AND fk_statut = 1";
104
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
105
+			if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
106
+			$sql .= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.facnumber, f.date_lim_reglement,";
107
+			$sql .= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
108 108
 			//$sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
109
-			$sql.= " ORDER BY datelimite ASC, f.facnumber ASC ";
110
-			$sql.= $db->plimit($max, 0);
109
+			$sql .= " ORDER BY datelimite ASC, f.facnumber ASC ";
110
+			$sql .= $db->plimit($max, 0);
111 111
 
112 112
 			$result = $db->query($sql);
113 113
 			if ($result)
114 114
 			{
115 115
 				$num = $db->num_rows($result);
116
-				$now=dol_now();
116
+				$now = dol_now();
117 117
 
118 118
 				$line = 0;
119 119
 				$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)';
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 				while ($line < $num)
122 122
 				{
123 123
 					$objp = $db->fetch_object($result);
124
-					$datelimite=$db->jdate($objp->datelimite);
124
+					$datelimite = $db->jdate($objp->datelimite);
125 125
                     $facturestatic->id = $objp->facid;
126 126
                     $facturestatic->ref = $objp->facnumber;
127 127
                     $facturestatic->type = $objp->type;
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
                     $societestatic->code_client = $objp->code_client;
137 137
                     $societestatic->logo = $objp->logo;
138 138
 
139
-					$late='';
139
+					$late = '';
140 140
 					if ($facturestatic->hasDelay()) {
141
-						$late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));
141
+						$late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day')));
142 142
 					}
143 143
 
144 144
                     $this->info_box_contents[$line][] = array(
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
 
162 162
                     $this->info_box_contents[$line][] = array(
163 163
                         'td' => 'class="right"',
164
-                        'text' => dol_print_date($datelimite,'day'),
164
+                        'text' => dol_print_date($datelimite, 'day'),
165 165
                     );
166 166
 
167 167
                     $this->info_box_contents[$line][] = array(
168 168
                         'td' => 'align="right" width="18"',
169
-                        'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$objp->am),
169
+                        'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am),
170 170
                     );
171 171
 
172 172
 					$line++;
173 173
 				}
174 174
 
175
-				if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills"));
175
+				if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoUnpaidCustomerBills"));
176 176
 
177 177
 				$db->free($result);
178 178
 			}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 *  @param	int		$nooutput	No print, only return string
202 202
 	 *	@return	string
203 203
 	 */
204
-    function showBox($head = null, $contents = null, $nooutput=0)
204
+    function showBox($head = null, $contents = null, $nooutput = 0)
205 205
     {
206 206
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
207 207
 	}
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -94,15 +94,21 @@  discard block
 block discarded – undo
94 94
 			$sql.= " f.paye, f.fk_statut, f.rowid as facid";
95 95
 			$sql.= ", sum(pf.amount) as am";
96 96
 			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
97
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
97
+			if (!$user->rights->societe->client->voir && !$user->societe_id) {
98
+				$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
99
+			}
98 100
 			$sql.= ", ".MAIN_DB_PREFIX."facture as f";
99 101
 			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
100 102
 			$sql.= " WHERE f.fk_soc = s.rowid";
101 103
 			$sql.= " AND f.entity = ".$conf->entity;
102 104
 			$sql.= " AND f.paye = 0";
103 105
 			$sql.= " AND fk_statut = 1";
104
-			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
105
-			if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
106
+			if (!$user->rights->societe->client->voir && !$user->societe_id) {
107
+				$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
108
+			}
109
+			if($user->societe_id) {
110
+				$sql.= " AND s.rowid = ".$user->societe_id;
111
+			}
106 112
 			$sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.facnumber, f.date_lim_reglement,";
107 113
 			$sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
108 114
 			//$sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
@@ -172,11 +178,12 @@  discard block
 block discarded – undo
172 178
 					$line++;
173 179
 				}
174 180
 
175
-				if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills"));
181
+				if ($num==0) {
182
+					$this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills"));
183
+				}
176 184
 
177 185
 				$db->free($result);
178
-			}
179
-			else
186
+			} else
180 187
 			{
181 188
                 $this->info_box_contents[0][0] = array(
182 189
                     'td' => '',
@@ -184,8 +191,7 @@  discard block
 block discarded – undo
184 191
                     'text' => ($db->error().' sql='.$sql),
185 192
                 );
186 193
 			}
187
-		}
188
-		else {
194
+		} else {
189 195
             $this->info_box_contents[0][0] = array(
190 196
                 'td' => 'align="left" class="nohover opacitymedium"',
191 197
                 'text' => $langs->trans("ReadPermissionNotAllowed")
Please login to merge, or discard this patch.
htdocs/core/boxes/box_graph_propales_permonth.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *  Load data into info_box_contents array to show array later.
59 59
 	 *
60 60
 	 *  @param	int		$max        Maximum number of records to load
61
-     *  @return	void
61
+	 *  @return	void
62 62
 	 */
63 63
 	function loadBox($max=5)
64 64
 	{
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 			else
251 251
 			{
252 252
 				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
253
-    	        										'maxlength'=>500,
254
-	            										'text' => $mesg);
253
+														'maxlength'=>500,
254
+														'text' => $mesg);
255 255
 			}
256 256
 
257 257
 		}
258 258
 		else {
259 259
 			$this->info_box_contents[0][0] = array(
260
-			    'td' => 'align="left" class="nohover opacitymedium"',
261
-                'text' => $langs->trans("ReadPermissionNotAllowed")
260
+				'td' => 'align="left" class="nohover opacitymedium"',
261
+				'text' => $langs->trans("ReadPermissionNotAllowed")
262 262
 			);
263 263
 		}
264 264
 	}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 	 *  @param	int		$nooutput	No print, only return string
272 272
 	 *	@return	string
273 273
 	 */
274
-    function showBox($head = null, $contents = null, $nooutput=0)
275
-    {
274
+	function showBox($head = null, $contents = null, $nooutput=0)
275
+	{
276 276
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
277 277
 	}
278 278
 
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class box_graph_propales_permonth extends ModeleBoxes
30 30
 {
31
-	var $boxcode="propalpermonth";
32
-	var $boximg="object_propal";
33
-	var $boxlabel="BoxProposalsPerMonth";
31
+	var $boxcode = "propalpermonth";
32
+	var $boximg = "object_propal";
33
+	var $boxlabel = "BoxProposalsPerMonth";
34 34
 	var $depends = array("propal");
35 35
 
36 36
 	var $db;
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	 * 	@param	DoliDB	$db			Database handler
46 46
 	 *  @param	string	$param		More parameters
47 47
 	 */
48
-	function __construct($db,$param)
48
+	function __construct($db, $param)
49 49
 	{
50 50
 		global $user;
51 51
 
52
-		$this->db=$db;
52
+		$this->db = $db;
53 53
 
54
-		$this->hidden=! ($user->rights->propale->lire);
54
+		$this->hidden = !($user->rights->propale->lire);
55 55
 	}
56 56
 
57 57
 	/**
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
 	 *  @param	int		$max        Maximum number of records to load
61 61
      *  @return	void
62 62
 	 */
63
-	function loadBox($max=5)
63
+	function loadBox($max = 5)
64 64
 	{
65 65
 		global $conf, $user, $langs, $db;
66 66
 
67
-		$this->max=$max;
67
+		$this->max = $max;
68 68
 
69
-		$refreshaction='refresh_'.$this->boxcode;
69
+		$refreshaction = 'refresh_'.$this->boxcode;
70 70
 
71 71
 		//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
72 72
 		//$propalstatic=new Propal($db);
73 73
 
74
-		$text = $langs->trans("BoxProposalsPerMonth",$max);
74
+		$text = $langs->trans("BoxProposalsPerMonth", $max);
75 75
 		$this->info_box_head = array(
76 76
 				'text' => $text,
77 77
 				'limit'=> dol_strlen($text),
78
-				'graph'=> 1,		// Set to 1 if it's a box graph
78
+				'graph'=> 1, // Set to 1 if it's a box graph
79 79
 				'sublink'=>'',
80 80
 				'subtext'=>$langs->trans("Filter"),
81 81
 				'subpicto'=>'filter.png',
@@ -83,64 +83,64 @@  discard block
 block discarded – undo
83 83
 				'target'=>'none'	// Set '' to get target="_blank"
84 84
 		);
85 85
 
86
-		$dir=''; 	// We don't need a path because image file will not be saved into disk
87
-		$prefix='';
88
-		$socid=0;
89
-		if ($user->societe_id) $socid=$user->societe_id;
90
-		if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-';	// If user has no permission to see all, output dir is specific to user
86
+		$dir = ''; // We don't need a path because image file will not be saved into disk
87
+		$prefix = '';
88
+		$socid = 0;
89
+		if ($user->societe_id) $socid = $user->societe_id;
90
+		if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
91 91
 
92 92
 		if ($user->rights->propale->lire)
93 93
 		{
94
-			$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
95
-			$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
96
-			$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
94
+			$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
95
+			$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
96
+			$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
97 97
 
98 98
 			include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
99 99
 			include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
100
-			$autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
101
-			if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
100
+			$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
101
+			if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
102 102
 			{
103
-				$endyear=GETPOST($param_year,'int');
104
-				$shownb=GETPOST($param_shownb,'alpha');
105
-				$showtot=GETPOST($param_showtot,'alpha');
103
+				$endyear = GETPOST($param_year, 'int');
104
+				$shownb = GETPOST($param_shownb, 'alpha');
105
+				$showtot = GETPOST($param_showtot, 'alpha');
106 106
 			}
107 107
 			else
108 108
 			{
109
-				$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
110
-				$endyear=$tmparray['year'];
111
-				$shownb=$tmparray['shownb'];
112
-				$showtot=$tmparray['showtot'];
109
+				$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
110
+				$endyear = $tmparray['year'];
111
+				$shownb = $tmparray['shownb'];
112
+				$showtot = $tmparray['showtot'];
113 113
 			}
114
-			if (empty($shownb) && empty($showtot)) $showtot=1;
115
-			$nowarray=dol_getdate(dol_now(),true);
116
-			if (empty($endyear)) $endyear=$nowarray['year'];
117
-			$startyear=$endyear-1;
118
-			$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
119
-			$HEIGHT='192';
114
+			if (empty($shownb) && empty($showtot)) $showtot = 1;
115
+			$nowarray = dol_getdate(dol_now(), true);
116
+			if (empty($endyear)) $endyear = $nowarray['year'];
117
+			$startyear = $endyear - 1;
118
+			$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
119
+			$HEIGHT = '192';
120 120
 
121 121
 			$stats = new PropaleStats($this->db, $socid, 0);
122 122
 
123 123
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
124 124
 			if ($shownb)
125 125
 			{
126
-				$data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
127
-				$datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars');
126
+				$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
127
+				$datatype1 = array_pad(array(), ($endyear - $startyear + 1), 'bars');
128 128
 
129 129
 				$filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png";
130 130
 				$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&amp;file=propalsnbinyear-'.$endyear.'.png';
131 131
 
132 132
 				$px1 = new DolGraph();
133 133
 				$mesg = $px1->isGraphKo();
134
-				if (! $mesg)
134
+				if (!$mesg)
135 135
 				{
136 136
 					$px1->SetType($datatype1);
137 137
 					$px1->SetData($data1);
138 138
 					unset($data1);
139 139
 					$px1->SetPrecisionY(0);
140
-					$i=$startyear;$legend=array();
140
+					$i = $startyear; $legend = array();
141 141
 					while ($i <= $endyear)
142 142
 					{
143
-						$legend[]=$i;
143
+						$legend[] = $i;
144 144
 						$i++;
145 145
 					}
146 146
 					$px1->SetLegend($legend);
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 					$px1->SetHorizTickIncrement(1);
153 153
 					$px1->SetPrecisionY(0);
154 154
 					$px1->SetCssPrefix("cssboxes");
155
-					$px1->mode='depth';
155
+					$px1->mode = 'depth';
156 156
 					$px1->SetTitle($langs->trans("NumberOfProposalsByMonth"));
157 157
 
158
-					$px1->draw($filenamenb,$fileurlnb);
158
+					$px1->draw($filenamenb, $fileurlnb);
159 159
 				}
160 160
 			}
161 161
 
162 162
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
163 163
 			if ($showtot)
164 164
 			{
165
-				$data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
166
-				$datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars');
165
+				$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
166
+				$datatype2 = array_pad(array(), ($endyear - $startyear + 1), 'bars');
167 167
 				//$datatype2 = array('lines','bars');
168 168
 
169 169
 				$filenamenb = $dir."/".$prefix."propalsamountinyear-".$endyear.".png";
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
 
173 173
 				$px2 = new DolGraph();
174 174
 				$mesg = $px2->isGraphKo();
175
-				if (! $mesg)
175
+				if (!$mesg)
176 176
 				{
177 177
 					$px2->SetType($datatype2);
178 178
 					$px2->SetData($data2);
179 179
 					unset($data2);
180 180
 					$px2->SetPrecisionY(0);
181
-					$i=$startyear;$legend=array();
181
+					$i = $startyear; $legend = array();
182 182
 					while ($i <= $endyear)
183 183
 					{
184
-						$legend[]=$i;
184
+						$legend[] = $i;
185 185
 						$i++;
186 186
 					}
187 187
 					$px2->SetLegend($legend);
@@ -193,63 +193,63 @@  discard block
 block discarded – undo
193 193
 					$px2->SetHorizTickIncrement(1);
194 194
 					$px2->SetPrecisionY(0);
195 195
 					$px2->SetCssPrefix("cssboxes");
196
-					$px2->mode='depth';
196
+					$px2->mode = 'depth';
197 197
 					$px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
198 198
 
199
-					$px2->draw($filenamenb,$fileurlnb);
199
+					$px2->draw($filenamenb, $fileurlnb);
200 200
 				}
201 201
 			}
202 202
 
203 203
 			if (empty($conf->use_javascript_ajax))
204 204
 			{
205 205
 				$langs->load("errors");
206
-				$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
206
+				$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
207 207
 			}
208 208
 
209
-			if (! $mesg)
209
+			if (!$mesg)
210 210
 			{
211
-				$stringtoshow='';
212
-				$stringtoshow.='<script type="text/javascript" language="javascript">
211
+				$stringtoshow = '';
212
+				$stringtoshow .= '<script type="text/javascript" language="javascript">
213 213
 					jQuery(document).ready(function() {
214 214
 						jQuery("#idsubimg'.$this->boxcode.'").click(function() {
215 215
 							jQuery("#idfilter'.$this->boxcode.'").toggle();
216 216
 						});
217 217
 					});
218 218
 					</script>';
219
-				$stringtoshow.='<div class="center hideobject divboxfilter" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
220
-				$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
221
-				$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
222
-				$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
223
-				$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfProposalsByMonth");
224
-				$stringtoshow.=' &nbsp; ';
225
-				$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfProposalsByMonthHT");
226
-				$stringtoshow.='<br>';
227
-				$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
228
-				$stringtoshow.='<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"),'refresh.png','','',1).'">';
229
-				$stringtoshow.='</form>';
230
-				$stringtoshow.='</div>';
219
+				$stringtoshow .= '<div class="center hideobject divboxfilter" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
220
+				$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
221
+				$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
222
+				$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
223
+				$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfProposalsByMonth");
224
+				$stringtoshow .= ' &nbsp; ';
225
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfProposalsByMonthHT");
226
+				$stringtoshow .= '<br>';
227
+				$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
228
+				$stringtoshow .= '<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
229
+				$stringtoshow .= '</form>';
230
+				$stringtoshow .= '</div>';
231 231
 				if ($shownb && $showtot)
232 232
 				{
233
-					$stringtoshow.='<div class="fichecenter">';
234
-					$stringtoshow.='<div class="fichehalfleft">';
233
+					$stringtoshow .= '<div class="fichecenter">';
234
+					$stringtoshow .= '<div class="fichehalfleft">';
235 235
 				}
236
-				if ($shownb) $stringtoshow.=$px1->show();
236
+				if ($shownb) $stringtoshow .= $px1->show();
237 237
 				if ($shownb && $showtot)
238 238
 				{
239
-					$stringtoshow.='</div>';
240
-					$stringtoshow.='<div class="fichehalfright">';
239
+					$stringtoshow .= '</div>';
240
+					$stringtoshow .= '<div class="fichehalfright">';
241 241
 				}
242
-				if ($showtot) $stringtoshow.=$px2->show();
242
+				if ($showtot) $stringtoshow .= $px2->show();
243 243
 				if ($shownb && $showtot)
244 244
 				{
245
-					$stringtoshow.='</div>';
246
-					$stringtoshow.='</div>';
245
+					$stringtoshow .= '</div>';
246
+					$stringtoshow .= '</div>';
247 247
 				}
248
-				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
248
+				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"', 'textnoformat'=>$stringtoshow);
249 249
 			}
250 250
 			else
251 251
 			{
252
-				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
252
+				$this->info_box_contents[0][0] = array('td' => 'align="left" class="nohover"',
253 253
     	        										'maxlength'=>500,
254 254
 	            										'text' => $mesg);
255 255
 			}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 *  @param	int		$nooutput	No print, only return string
272 272
 	 *	@return	string
273 273
 	 */
274
-    function showBox($head = null, $contents = null, $nooutput=0)
274
+    function showBox($head = null, $contents = null, $nooutput = 0)
275 275
     {
276 276
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
277 277
 	}
Please login to merge, or discard this patch.
Braces   +28 added lines, -14 removed lines patch added patch discarded remove patch
@@ -86,8 +86,13 @@  discard block
 block discarded – undo
86 86
 		$dir=''; 	// We don't need a path because image file will not be saved into disk
87 87
 		$prefix='';
88 88
 		$socid=0;
89
-		if ($user->societe_id) $socid=$user->societe_id;
90
-		if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-';	// If user has no permission to see all, output dir is specific to user
89
+		if ($user->societe_id) {
90
+			$socid=$user->societe_id;
91
+		}
92
+		if (! $user->rights->societe->client->voir || $socid) {
93
+			$prefix.='private-'.$user->id.'-';
94
+		}
95
+		// If user has no permission to see all, output dir is specific to user
91 96
 
92 97
 		if ($user->rights->propale->lire)
93 98
 		{
@@ -103,17 +108,20 @@  discard block
 block discarded – undo
103 108
 				$endyear=GETPOST($param_year,'int');
104 109
 				$shownb=GETPOST($param_shownb,'alpha');
105 110
 				$showtot=GETPOST($param_showtot,'alpha');
106
-			}
107
-			else
111
+			} else
108 112
 			{
109 113
 				$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
110 114
 				$endyear=$tmparray['year'];
111 115
 				$shownb=$tmparray['shownb'];
112 116
 				$showtot=$tmparray['showtot'];
113 117
 			}
114
-			if (empty($shownb) && empty($showtot)) $showtot=1;
118
+			if (empty($shownb) && empty($showtot)) {
119
+				$showtot=1;
120
+			}
115 121
 			$nowarray=dol_getdate(dol_now(),true);
116
-			if (empty($endyear)) $endyear=$nowarray['year'];
122
+			if (empty($endyear)) {
123
+				$endyear=$nowarray['year'];
124
+			}
117 125
 			$startyear=$endyear-1;
118 126
 			$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
119 127
 			$HEIGHT='192';
@@ -167,8 +175,12 @@  discard block
 block discarded – undo
167 175
 				//$datatype2 = array('lines','bars');
168 176
 
169 177
 				$filenamenb = $dir."/".$prefix."propalsamountinyear-".$endyear.".png";
170
-				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&amp;file=propalsamountinyear-'.$endyear.'.png';
171
-				if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstatssupplier&amp;file=propalsamountinyear-'.$endyear.'.png';
178
+				if ($mode == 'customer') {
179
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&amp;file=propalsamountinyear-'.$endyear.'.png';
180
+				}
181
+				if ($mode == 'supplier') {
182
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstatssupplier&amp;file=propalsamountinyear-'.$endyear.'.png';
183
+				}
172 184
 
173 185
 				$px2 = new DolGraph();
174 186
 				$mesg = $px2->isGraphKo();
@@ -233,29 +245,31 @@  discard block
 block discarded – undo
233 245
 					$stringtoshow.='<div class="fichecenter">';
234 246
 					$stringtoshow.='<div class="fichehalfleft">';
235 247
 				}
236
-				if ($shownb) $stringtoshow.=$px1->show();
248
+				if ($shownb) {
249
+					$stringtoshow.=$px1->show();
250
+				}
237 251
 				if ($shownb && $showtot)
238 252
 				{
239 253
 					$stringtoshow.='</div>';
240 254
 					$stringtoshow.='<div class="fichehalfright">';
241 255
 				}
242
-				if ($showtot) $stringtoshow.=$px2->show();
256
+				if ($showtot) {
257
+					$stringtoshow.=$px2->show();
258
+				}
243 259
 				if ($shownb && $showtot)
244 260
 				{
245 261
 					$stringtoshow.='</div>';
246 262
 					$stringtoshow.='</div>';
247 263
 				}
248 264
 				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
249
-			}
250
-			else
265
+			} else
251 266
 			{
252 267
 				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
253 268
     	        										'maxlength'=>500,
254 269
 	            										'text' => $mesg);
255 270
 			}
256 271
 
257
-		}
258
-		else {
272
+		} else {
259 273
 			$this->info_box_contents[0][0] = array(
260 274
 			    'td' => 'align="left" class="nohover opacitymedium"',
261 275
                 'text' => $langs->trans("ReadPermissionNotAllowed")
Please login to merge, or discard this patch.
htdocs/core/boxes/box_graph_product_distribution.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$this->db=$db;
54 54
 
55 55
 		$this->hidden = ! (
56
-		    (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
56
+			(! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
57 57
 		 || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
58 58
 		 || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
59 59
 		);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *  Load data into info_box_contents array to show array later.
64 64
 	 *
65 65
 	 *  @param	int		$max        Maximum number of records to load
66
-     *  @return	void
66
+	 *  @return	void
67 67
 	 */
68 68
 	function loadBox($max=5)
69 69
 	{
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
 
317 317
 		if (empty($nbofgraph))
318 318
 		{
319
-		    $langs->load("errors");
320
-		    $mesg=$langs->trans("ReadPermissionNotAllowed");
319
+			$langs->load("errors");
320
+			$mesg=$langs->trans("ReadPermissionNotAllowed");
321 321
 		}
322 322
 		if (empty($conf->use_javascript_ajax))
323 323
 		{
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		else
392 392
 		{
393 393
 			$this->info_box_contents[0][0] = array(
394
-			    'td' => 'align="left" class="nohover opacitymedium"',
394
+				'td' => 'align="left" class="nohover opacitymedium"',
395 395
 				'maxlength'=>500,
396 396
 				'text' => $mesg
397 397
 			);
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 *  @param	int		$nooutput	No print, only return string
408 408
 	 *	@return	string
409 409
 	 */
410
-    function showBox($head = null, $contents = null, $nooutput=0)
411
-    {
410
+	function showBox($head = null, $contents = null, $nooutput=0)
411
+	{
412 412
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
413 413
 	}
414 414
 
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class box_graph_product_distribution extends ModeleBoxes
30 30
 {
31
-	var $boxcode="productdistribution";
32
-	var $boximg="object_product";
33
-	var $boxlabel="BoxProductDistribution";
34
-	var $depends = array("product|service","facture|propal|commande");
31
+	var $boxcode = "productdistribution";
32
+	var $boximg = "object_product";
33
+	var $boxlabel = "BoxProductDistribution";
34
+	var $depends = array("product|service", "facture|propal|commande");
35 35
 
36 36
 	var $db;
37 37
 	var $param;
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 	 * 	@param	DoliDB	$db			Database handler
47 47
 	 *  @param	string	$param		More parameters
48 48
 	 */
49
-	function __construct($db,$param)
49
+	function __construct($db, $param)
50 50
 	{
51 51
 		global $user, $conf;
52 52
 
53
-		$this->db=$db;
53
+		$this->db = $db;
54 54
 
55
-		$this->hidden = ! (
56
-		    (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
57
-		 || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
58
-		 || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
55
+		$this->hidden = !(
56
+		    (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
57
+		 || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
58
+		 || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
59 59
 		);
60 60
 	}
61 61
 
@@ -65,52 +65,52 @@  discard block
 block discarded – undo
65 65
 	 *  @param	int		$max        Maximum number of records to load
66 66
      *  @return	void
67 67
 	 */
68
-	function loadBox($max=5)
68
+	function loadBox($max = 5)
69 69
 	{
70 70
 		global $conf, $user, $langs, $db;
71 71
 
72
-		$this->max=$max;
72
+		$this->max = $max;
73 73
 
74
-		$refreshaction='refresh_'.$this->boxcode;
74
+		$refreshaction = 'refresh_'.$this->boxcode;
75 75
 
76 76
 		include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
77 77
 		include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
78 78
 		include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
79 79
 
80
-		$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
81
-		$param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
82
-		$param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
83
-		$param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
84
-		$autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
85
-		if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
80
+		$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
81
+		$param_showinvoicenb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
82
+		$param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
83
+		$param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
84
+		$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
85
+		if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
86 86
 		{
87
-			$year=GETPOST($param_year,'int');
88
-			$showinvoicenb=GETPOST($param_showinvoicenb,'alpha');
89
-			$showpropalnb=GETPOST($param_showpropalnb,'alpha');
90
-			$showordernb=GETPOST($param_showordernb,'alpha');
87
+			$year = GETPOST($param_year, 'int');
88
+			$showinvoicenb = GETPOST($param_showinvoicenb, 'alpha');
89
+			$showpropalnb = GETPOST($param_showpropalnb, 'alpha');
90
+			$showordernb = GETPOST($param_showordernb, 'alpha');
91 91
 		}
92 92
 		else
93 93
 		{
94
-			$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
95
-			$year=$tmparray['year'];
96
-			$showinvoicenb=$tmparray['showinvoicenb'];
97
-			$showpropalnb=$tmparray['showpropalnb'];
98
-			$showordernb=$tmparray['showordernb'];
94
+			$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
95
+			$year = $tmparray['year'];
96
+			$showinvoicenb = $tmparray['showinvoicenb'];
97
+			$showpropalnb = $tmparray['showpropalnb'];
98
+			$showordernb = $tmparray['showordernb'];
99 99
 		}
100
-		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
101
-		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
102
-		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
103
-		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
100
+		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; }
101
+		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb = 0;
102
+		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb = 0;
103
+		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb = 0;
104 104
 
105
-		$nowarray=dol_getdate(dol_now(),true);
106
-		if (empty($year)) $year=$nowarray['year'];
105
+		$nowarray = dol_getdate(dol_now(), true);
106
+		if (empty($year)) $year = $nowarray['year'];
107 107
 
108
-		$nbofgraph=0;
108
+		$nbofgraph = 0;
109 109
 		if ($showinvoicenb) $nbofgraph++;
110 110
 		if ($showpropalnb)  $nbofgraph++;
111 111
 		if ($showordernb)   $nbofgraph++;
112 112
 
113
-		$text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year;
113
+		$text = $langs->trans("BoxProductDistribution", $max).' - '.$langs->trans("Year").': '.$year;
114 114
 		$this->info_box_head = array(
115 115
 				'text' => $text,
116 116
 				'limit'=> dol_strlen($text),
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 		);
124 124
 
125 125
 
126
-		$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
127
-		if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
128
-		if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
126
+		$paramtitle = $langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
127
+		if (empty($conf->produit->enabled)) $paramtitle = $langs->transnoentitiesnoconv("Services");
128
+		if (empty($conf->service->enabled)) $paramtitle = $langs->transnoentitiesnoconv("Products");
129 129
 
130
-		$socid=empty($user->societe_id)?0:$user->societe_id;
131
-		$userid=0;	// No filter on user creation
130
+		$socid = empty($user->societe_id) ? 0 : $user->societe_id;
131
+		$userid = 0; // No filter on user creation
132 132
 
133
-		$WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
134
-		$HEIGHT='192';
133
+		$WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320';
134
+		$HEIGHT = '192';
135 135
 
136
-		if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
136
+		if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
137 137
 		{
138 138
 
139 139
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
@@ -142,34 +142,34 @@  discard block
 block discarded – undo
142 142
 				include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
143 143
 
144 144
 				$showpointvalue = 1; $nocolor = 0;
145
-				$mode='customer';
146
-				$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0));
147
-				$data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
145
+				$mode = 'customer';
146
+				$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
147
+				$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
148 148
 				if (empty($data1))
149 149
 				{
150
-					$showpointvalue=0;
151
-					$nocolor=1;
152
-					$data1=array(array(0=>$langs->trans("None"),1=>1));
150
+					$showpointvalue = 0;
151
+					$nocolor = 1;
152
+					$data1 = array(array(0=>$langs->trans("None"), 1=>1));
153 153
 				}
154 154
 				$filenamenb = $dir."/prodserforinvoice-".$year.".png";
155 155
 				$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&amp;file=prodserforinvoice-'.$year.'.png';
156 156
 
157 157
 				$px1 = new DolGraph();
158 158
 				$mesg = $px1->isGraphKo();
159
-				if (! $mesg)
159
+				if (!$mesg)
160 160
 				{
161
-					$i=0;$tot=count($data1);$legend=array();
161
+					$i = 0; $tot = count($data1); $legend = array();
162 162
 					while ($i <= $tot)
163 163
 					{
164
-						$data1[$i][0]=dol_trunc($data1[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
165
-						$legend[]=$data1[$i][0];
164
+						$data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
165
+						$legend[] = $data1[$i][0];
166 166
 						$i++;
167 167
 					}
168 168
 
169 169
 					$px1->SetData($data1);
170 170
 					unset($data1);
171 171
 
172
-					if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
172
+					if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220)));
173 173
 					$px1->SetPrecisionY(0);
174 174
 					$px1->SetLegend($legend);
175 175
 					$px1->setShowLegend(0);
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 					$px1->SetCssPrefix("cssboxes");
186 186
 					//$px1->mode='depth';
187 187
 					$px1->SetType(array('pie'));
188
-					$px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices")));
188
+					$px1->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Invoices")));
189 189
 					$px1->combine = 0.05;
190 190
 
191
-					$px1->draw($filenamenb,$fileurlnb);
191
+					$px1->draw($filenamenb, $fileurlnb);
192 192
 				}
193 193
 			}
194 194
 		}
195 195
 
196
-		if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
196
+		if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
197 197
 		{
198 198
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
199 199
 			if ($showpropalnb)
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 				include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
202 202
 
203 203
 				$showpointvalue = 1; $nocolor = 0;
204
-				$stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0));
205
-				$data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
204
+				$stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0));
205
+				$data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
206 206
 				if (empty($data2))
207 207
 				{
208 208
 					$showpointvalue = 0;
209 209
 					$nocolor = 1;
210
-					$data2=array(array(0=>$langs->trans("None"),1=>1));
210
+					$data2 = array(array(0=>$langs->trans("None"), 1=>1));
211 211
 				}
212 212
 
213 213
 				$filenamenb = $dir."/prodserforpropal-".$year.".png";
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 
216 216
 				$px2 = new DolGraph();
217 217
 				$mesg = $px2->isGraphKo();
218
-				if (! $mesg)
218
+				if (!$mesg)
219 219
 				{
220
-					$i=0;$tot=count($data2);$legend=array();
220
+					$i = 0; $tot = count($data2); $legend = array();
221 221
 					while ($i <= $tot)
222 222
 					{
223
-						$data2[$i][0]=dol_trunc($data2[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
224
-						$legend[]=$data2[$i][0];
223
+						$data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
224
+						$legend[] = $data2[$i][0];
225 225
 						$i++;
226 226
 					}
227 227
 
228 228
 					$px2->SetData($data2);
229 229
 					unset($data2);
230 230
 
231
-					if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
231
+					if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220)));
232 232
 					$px2->SetPrecisionY(0);
233 233
 					$px2->SetLegend($legend);
234 234
 					$px2->setShowLegend(0);
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 					$px2->SetCssPrefix("cssboxes");
245 245
 					//$px2->mode='depth';
246 246
 					$px2->SetType(array('pie'));
247
-					$px2->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Proposals")));
247
+					$px2->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Proposals")));
248 248
 					$px2->combine = 0.05;
249 249
 
250
-					$px2->draw($filenamenb,$fileurlnb);
250
+					$px2->draw($filenamenb, $fileurlnb);
251 251
 				}
252 252
 			}
253 253
 		}
254 254
 
255
-		if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
255
+		if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
256 256
 		{
257 257
 			$langs->load("orders");
258 258
 
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
 				include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
263 263
 
264 264
 				$showpointvalue = 1; $nocolor = 0;
265
-				$mode='customer';
266
-				$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0));
267
-				$data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
265
+				$mode = 'customer';
266
+				$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
267
+				$data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
268 268
 				if (empty($data3))
269 269
 				{
270 270
 					$showpointvalue = 0;
271 271
 					$nocolor = 1;
272
-					$data3=array(array(0=>$langs->trans("None"),1=>1));
272
+					$data3 = array(array(0=>$langs->trans("None"), 1=>1));
273 273
 				}
274 274
 
275 275
 				$filenamenb = $dir."/prodserfororder-".$year.".png";
@@ -277,20 +277,20 @@  discard block
 block discarded – undo
277 277
 
278 278
 				$px3 = new DolGraph();
279 279
 				$mesg = $px3->isGraphKo();
280
-				if (! $mesg)
280
+				if (!$mesg)
281 281
 				{
282
-					$i=0;$tot=count($data3);$legend=array();
282
+					$i = 0; $tot = count($data3); $legend = array();
283 283
 					while ($i <= $tot)
284 284
 					{
285
-						$data3[$i][0]=dol_trunc($data3[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
286
-						$legend[]=$data3[$i][0];
285
+						$data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
286
+						$legend[] = $data3[$i][0];
287 287
 						$i++;
288 288
 					}
289 289
 
290 290
 					$px3->SetData($data3);
291 291
 					unset($data3);
292 292
 
293
-					if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
293
+					if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220)));
294 294
 					$px3->SetPrecisionY(0);
295 295
 					$px3->SetLegend($legend);
296 296
 					$px3->setShowLegend(0);
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 					$px3->SetCssPrefix("cssboxes");
307 307
 					//$px3->mode='depth';
308 308
 					$px3->SetType(array('pie'));
309
-					$px3->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Orders")));
309
+					$px3->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Orders")));
310 310
 					$px3->combine = 0.05;
311 311
 
312
-					$px3->draw($filenamenb,$fileurlnb);
312
+					$px3->draw($filenamenb, $fileurlnb);
313 313
 				}
314 314
 			}
315 315
 		}
@@ -317,76 +317,76 @@  discard block
 block discarded – undo
317 317
 		if (empty($nbofgraph))
318 318
 		{
319 319
 		    $langs->load("errors");
320
-		    $mesg=$langs->trans("ReadPermissionNotAllowed");
320
+		    $mesg = $langs->trans("ReadPermissionNotAllowed");
321 321
 		}
322 322
 		if (empty($conf->use_javascript_ajax))
323 323
 		{
324 324
 			$langs->load("errors");
325
-			$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
325
+			$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
326 326
 		}
327 327
 
328
-		if (! $mesg)
328
+		if (!$mesg)
329 329
 		{
330
-			$stringtoshow='';
331
-			$stringtoshow.='<script type="text/javascript" language="javascript">
330
+			$stringtoshow = '';
331
+			$stringtoshow .= '<script type="text/javascript" language="javascript">
332 332
 				jQuery(document).ready(function() {
333 333
 					jQuery("#idsubimg'.$this->boxcode.'").click(function() {
334 334
 						jQuery("#idfilter'.$this->boxcode.'").toggle();
335 335
 					});
336 336
 				});
337 337
 			</script>';
338
-			$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
339
-			$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
340
-			$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
341
-			$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
342
-			if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
338
+			$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
339
+			$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
340
+			$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
341
+			$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
342
+			if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire))
343 343
 			{
344
-				$stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices");
345
-				$stringtoshow.=' &nbsp; ';
344
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb ? ' checked' : '').'> '.$langs->trans("ForCustomersInvoices");
345
+				$stringtoshow .= ' &nbsp; ';
346 346
 			}
347
-			if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
347
+			if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire))
348 348
 			{
349
-				$stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals");
350
-				$stringtoshow.='&nbsp;';
349
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb ? ' checked' : '').'> '.$langs->trans("ForProposals");
350
+				$stringtoshow .= '&nbsp;';
351 351
 			}
352
-			if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
352
+			if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire))
353 353
 			{
354
-				$stringtoshow.='<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb?' checked':'').'> '.$langs->trans("ForCustomersOrders");
354
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb ? ' checked' : '').'> '.$langs->trans("ForCustomersOrders");
355 355
 			}
356
-			$stringtoshow.='<br>';
357
-			$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
358
-			$stringtoshow.='<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto('','refresh.png','','',1).'">';
359
-			$stringtoshow.='</form>';
360
-			$stringtoshow.='</div>';
356
+			$stringtoshow .= '<br>';
357
+			$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
358
+			$stringtoshow .= '<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto('', 'refresh.png', '', '', 1).'">';
359
+			$stringtoshow .= '</form>';
360
+			$stringtoshow .= '</div>';
361 361
 
362 362
 			if ($nbofgraph == 1)
363 363
 			{
364
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
365
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
366
-				else $stringtoshow.=$px3->show();
364
+				if ($showinvoicenb) $stringtoshow .= $px1->show();
365
+				else if ($showpropalnb) $stringtoshow .= $px2->show();
366
+				else $stringtoshow .= $px3->show();
367 367
 			}
368 368
 			if ($nbofgraph == 2)
369 369
 			{
370
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
371
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
372
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
373
-				$stringtoshow.='</div><div class="fichehalfright">';
374
-				if ($showordernb) $stringtoshow.=$px3->show();
375
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
376
-				$stringtoshow.='</div></div></div>';
370
+				$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
371
+				if ($showinvoicenb) $stringtoshow .= $px1->show();
372
+				else if ($showpropalnb) $stringtoshow .= $px2->show();
373
+				$stringtoshow .= '</div><div class="fichehalfright">';
374
+				if ($showordernb) $stringtoshow .= $px3->show();
375
+				else if ($showpropalnb) $stringtoshow .= $px2->show();
376
+				$stringtoshow .= '</div></div></div>';
377 377
 			}
378 378
 			if ($nbofgraph == 3)
379 379
 			{
380
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
381
-				$stringtoshow.=$px1->show();
382
-				$stringtoshow.='</div><div class="fichehalfright">';
383
-				$stringtoshow.=$px2->show();
384
-				$stringtoshow.='</div></div></div>';
385
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter">';
386
-				$stringtoshow.=$px3->show();
387
-				$stringtoshow.='</div></div>';
380
+				$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
381
+				$stringtoshow .= $px1->show();
382
+				$stringtoshow .= '</div><div class="fichehalfright">';
383
+				$stringtoshow .= $px2->show();
384
+				$stringtoshow .= '</div></div></div>';
385
+				$stringtoshow .= '<div class="fichecenter"><div class="containercenter">';
386
+				$stringtoshow .= $px3->show();
387
+				$stringtoshow .= '</div></div>';
388 388
 			}
389
-			$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
389
+			$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"', 'textnoformat'=>$stringtoshow);
390 390
 		}
391 391
 		else
392 392
 		{
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 *  @param	int		$nooutput	No print, only return string
408 408
 	 *	@return	string
409 409
 	 */
410
-    function showBox($head = null, $contents = null, $nooutput=0)
410
+    function showBox($head = null, $contents = null, $nooutput = 0)
411 411
     {
412 412
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
413 413
 	}
Please login to merge, or discard this patch.
Braces   +55 added lines, -23 removed lines patch added patch discarded remove patch
@@ -88,8 +88,7 @@  discard block
 block discarded – undo
88 88
 			$showinvoicenb=GETPOST($param_showinvoicenb,'alpha');
89 89
 			$showpropalnb=GETPOST($param_showpropalnb,'alpha');
90 90
 			$showordernb=GETPOST($param_showordernb,'alpha');
91
-		}
92
-		else
91
+		} else
93 92
 		{
94 93
 			$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
95 94
 			$year=$tmparray['year'];
@@ -98,17 +97,31 @@  discard block
 block discarded – undo
98 97
 			$showordernb=$tmparray['showordernb'];
99 98
 		}
100 99
 		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
101
-		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
102
-		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
103
-		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
100
+		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) {
101
+			$showinvoicenb=0;
102
+		}
103
+		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) {
104
+			$showpropalnb=0;
105
+		}
106
+		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) {
107
+			$showordernb=0;
108
+		}
104 109
 
105 110
 		$nowarray=dol_getdate(dol_now(),true);
106
-		if (empty($year)) $year=$nowarray['year'];
111
+		if (empty($year)) {
112
+			$year=$nowarray['year'];
113
+		}
107 114
 
108 115
 		$nbofgraph=0;
109
-		if ($showinvoicenb) $nbofgraph++;
110
-		if ($showpropalnb)  $nbofgraph++;
111
-		if ($showordernb)   $nbofgraph++;
116
+		if ($showinvoicenb) {
117
+			$nbofgraph++;
118
+		}
119
+		if ($showpropalnb) {
120
+			$nbofgraph++;
121
+		}
122
+		if ($showordernb) {
123
+			$nbofgraph++;
124
+		}
112 125
 
113 126
 		$text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year;
114 127
 		$this->info_box_head = array(
@@ -124,8 +137,12 @@  discard block
 block discarded – undo
124 137
 
125 138
 
126 139
 		$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
127
-		if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
128
-		if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
140
+		if (empty($conf->produit->enabled)) {
141
+			$paramtitle=$langs->transnoentitiesnoconv("Services");
142
+		}
143
+		if (empty($conf->service->enabled)) {
144
+			$paramtitle=$langs->transnoentitiesnoconv("Products");
145
+		}
129 146
 
130 147
 		$socid=empty($user->societe_id)?0:$user->societe_id;
131 148
 		$userid=0;	// No filter on user creation
@@ -169,7 +186,9 @@  discard block
 block discarded – undo
169 186
 					$px1->SetData($data1);
170 187
 					unset($data1);
171 188
 
172
-					if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
189
+					if ($nocolor) {
190
+						$px1->SetDataColor(array(array(220,220,220)));
191
+					}
173 192
 					$px1->SetPrecisionY(0);
174 193
 					$px1->SetLegend($legend);
175 194
 					$px1->setShowLegend(0);
@@ -228,7 +247,9 @@  discard block
 block discarded – undo
228 247
 					$px2->SetData($data2);
229 248
 					unset($data2);
230 249
 
231
-					if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
250
+					if ($nocolor) {
251
+						$px2->SetDataColor(array(array(220,220,220)));
252
+					}
232 253
 					$px2->SetPrecisionY(0);
233 254
 					$px2->SetLegend($legend);
234 255
 					$px2->setShowLegend(0);
@@ -290,7 +311,9 @@  discard block
 block discarded – undo
290 311
 					$px3->SetData($data3);
291 312
 					unset($data3);
292 313
 
293
-					if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
314
+					if ($nocolor) {
315
+						$px3->SetDataColor(array(array(220,220,220)));
316
+					}
294 317
 					$px3->SetPrecisionY(0);
295 318
 					$px3->SetLegend($legend);
296 319
 					$px3->setShowLegend(0);
@@ -361,18 +384,28 @@  discard block
 block discarded – undo
361 384
 
362 385
 			if ($nbofgraph == 1)
363 386
 			{
364
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
365
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
366
-				else $stringtoshow.=$px3->show();
387
+				if ($showinvoicenb) {
388
+					$stringtoshow.=$px1->show();
389
+				} else if ($showpropalnb) {
390
+					$stringtoshow.=$px2->show();
391
+				} else {
392
+					$stringtoshow.=$px3->show();
393
+				}
367 394
 			}
368 395
 			if ($nbofgraph == 2)
369 396
 			{
370 397
 				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
371
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
372
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
398
+				if ($showinvoicenb) {
399
+					$stringtoshow.=$px1->show();
400
+				} else if ($showpropalnb) {
401
+					$stringtoshow.=$px2->show();
402
+				}
373 403
 				$stringtoshow.='</div><div class="fichehalfright">';
374
-				if ($showordernb) $stringtoshow.=$px3->show();
375
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
404
+				if ($showordernb) {
405
+					$stringtoshow.=$px3->show();
406
+				} else if ($showpropalnb) {
407
+					$stringtoshow.=$px2->show();
408
+				}
376 409
 				$stringtoshow.='</div></div></div>';
377 410
 			}
378 411
 			if ($nbofgraph == 3)
@@ -387,8 +420,7 @@  discard block
 block discarded – undo
387 420
 				$stringtoshow.='</div></div>';
388 421
 			}
389 422
 			$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
390
-		}
391
-		else
423
+		} else
392 424
 		{
393 425
 			$this->info_box_contents[0][0] = array(
394 426
 			    'td' => 'align="left" class="nohover opacitymedium"',
Please login to merge, or discard this patch.
htdocs/core/boxes/box_graph_invoices_permonth.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *  Load data into info_box_contents array to show array later.
59 59
 	 *
60 60
 	 *  @param	int		$max        Maximum number of records to load
61
-     *  @return	void
61
+	 *  @return	void
62 62
 	 */
63 63
 	function loadBox($max=5)
64 64
 	{
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				$mesg = $px1->isGraphKo();
135 135
 				if (! $mesg)
136 136
 				{
137
-				    $langs->load("bills");
137
+					$langs->load("bills");
138 138
 
139
-				    $px1->SetData($data1);
139
+					$px1->SetData($data1);
140 140
 					unset($data1);
141 141
 					$px1->SetPrecisionY(0);
142 142
 					$i=$startyear;$legend=array();
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				$mesg = $px2->isGraphKo();
175 175
 				if (! $mesg)
176 176
 				{
177
-				    $langs->load("bills");
177
+					$langs->load("bills");
178 178
 
179 179
 					$px2->SetData($data2);
180 180
 					unset($data2);
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 			else
252 252
 			{
253 253
 				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
254
-    	        										'maxlength'=>500,
255
-	            										'text' => $mesg);
254
+														'maxlength'=>500,
255
+														'text' => $mesg);
256 256
 			}
257 257
 
258 258
 		}
259 259
 		else {
260 260
 			$this->info_box_contents[0][0] = array(
261
-			    'td' => 'align="left" class="nohover opacitymedium"',
262
-                'text' => $langs->trans("ReadPermissionNotAllowed")
261
+				'td' => 'align="left" class="nohover opacitymedium"',
262
+				'text' => $langs->trans("ReadPermissionNotAllowed")
263 263
 			);
264 264
 		}
265 265
 	}
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
 	 *  @param	int		$nooutput	No print, only return string
273 273
 	 *	@return	string
274 274
 	 */
275
-    function showBox($head = null, $contents = null, $nooutput=0)
276
-    {
275
+	function showBox($head = null, $contents = null, $nooutput=0)
276
+	{
277 277
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
278 278
 	}
279 279
 
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class box_graph_invoices_permonth extends ModeleBoxes
30 30
 {
31
-	var $boxcode="invoicespermonth";
32
-	var $boximg="object_bill";
33
-	var $boxlabel="BoxCustomersInvoicesPerMonth";
31
+	var $boxcode = "invoicespermonth";
32
+	var $boximg = "object_bill";
33
+	var $boxlabel = "BoxCustomersInvoicesPerMonth";
34 34
 	var $depends = array("facture");
35 35
 
36 36
 	var $db;
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	 * 	@param	DoliDB	$db			Database handler
46 46
 	 *  @param	string	$param		More parameters
47 47
 	 */
48
-	function __construct($db,$param)
48
+	function __construct($db, $param)
49 49
 	{
50 50
 		global $user;
51 51
 
52
-		$this->db=$db;
52
+		$this->db = $db;
53 53
 
54
-		$this->hidden = ! ($user->rights->facture->lire);
54
+		$this->hidden = !($user->rights->facture->lire);
55 55
 	}
56 56
 
57 57
 	/**
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 	 *  @param	int		$max        Maximum number of records to load
61 61
      *  @return	void
62 62
 	 */
63
-	function loadBox($max=5)
63
+	function loadBox($max = 5)
64 64
 	{
65 65
 		global $conf, $user, $langs, $db;
66 66
 
67
-		$this->max=$max;
67
+		$this->max = $max;
68 68
 
69
-		$refreshaction='refresh_'.$this->boxcode;
69
+		$refreshaction = 'refresh_'.$this->boxcode;
70 70
 
71 71
 		//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
72 72
 		//$facturestatic=new Facture($db);
73 73
 
74
-		$text = $langs->trans("BoxCustomersInvoicesPerMonth",$max);
74
+		$text = $langs->trans("BoxCustomersInvoicesPerMonth", $max);
75 75
 		$this->info_box_head = array(
76 76
 				'text' => $text,
77 77
 				'limit'=> dol_strlen($text),
@@ -83,48 +83,48 @@  discard block
 block discarded – undo
83 83
 				'target'=>'none'	// Set '' to get target="_blank"
84 84
 		);
85 85
 
86
-		$dir=''; 	// We don't need a path because image file will not be saved into disk
87
-		$prefix='';
88
-		$socid=0;
89
-		if ($user->societe_id) $socid=$user->societe_id;
90
-		if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-';	// If user has no permission to see all, output dir is specific to user
86
+		$dir = ''; // We don't need a path because image file will not be saved into disk
87
+		$prefix = '';
88
+		$socid = 0;
89
+		if ($user->societe_id) $socid = $user->societe_id;
90
+		if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
91 91
 
92 92
 		if ($user->rights->facture->lire)
93 93
 		{
94
-			$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
95
-			$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
96
-			$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
94
+			$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
95
+			$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
96
+			$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
97 97
 
98 98
 			include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
99 99
 			include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
100
-			$autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
101
-			if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
100
+			$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
101
+			if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
102 102
 			{
103
-				$endyear=GETPOST($param_year,'int');
104
-				$shownb=GETPOST($param_shownb,'alpha');
105
-				$showtot=GETPOST($param_showtot,'alpha');
103
+				$endyear = GETPOST($param_year, 'int');
104
+				$shownb = GETPOST($param_shownb, 'alpha');
105
+				$showtot = GETPOST($param_showtot, 'alpha');
106 106
 			}
107 107
 			else
108 108
 			{
109
-				$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
110
-				$endyear=$tmparray['year'];
111
-				$shownb=$tmparray['shownb'];
112
-				$showtot=$tmparray['showtot'];
109
+				$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
110
+				$endyear = $tmparray['year'];
111
+				$shownb = $tmparray['shownb'];
112
+				$showtot = $tmparray['showtot'];
113 113
 			}
114
-			if (empty($shownb) && empty($showtot)) $showtot=1;
115
-			$nowarray=dol_getdate(dol_now(),true);
116
-			if (empty($endyear)) $endyear=$nowarray['year'];
117
-			$startyear=$endyear-1;
118
-			$mode='customer';
119
-			$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
120
-			$HEIGHT='192';
114
+			if (empty($shownb) && empty($showtot)) $showtot = 1;
115
+			$nowarray = dol_getdate(dol_now(), true);
116
+			if (empty($endyear)) $endyear = $nowarray['year'];
117
+			$startyear = $endyear - 1;
118
+			$mode = 'customer';
119
+			$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
120
+			$HEIGHT = '192';
121 121
 
122 122
 			$stats = new FactureStats($this->db, $socid, $mode, 0);
123 123
 
124 124
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
125 125
 			if ($shownb)
126 126
 			{
127
-				$data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
127
+				$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
128 128
 
129 129
 				$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
130 130
 				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png';
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
 
133 133
 				$px1 = new DolGraph();
134 134
 				$mesg = $px1->isGraphKo();
135
-				if (! $mesg)
135
+				if (!$mesg)
136 136
 				{
137 137
 				    $langs->load("bills");
138 138
 
139 139
 				    $px1->SetData($data1);
140 140
 					unset($data1);
141 141
 					$px1->SetPrecisionY(0);
142
-					$i=$startyear;$legend=array();
142
+					$i = $startyear; $legend = array();
143 143
 					while ($i <= $endyear)
144 144
 					{
145
-						$legend[]=$i;
145
+						$legend[] = $i;
146 146
 						$i++;
147 147
 					}
148 148
 					$px1->SetLegend($legend);
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 					$px1->SetHorizTickIncrement(1);
155 155
 					$px1->SetPrecisionY(0);
156 156
 					$px1->SetCssPrefix("cssboxes");
157
-					$px1->mode='depth';
157
+					$px1->mode = 'depth';
158 158
 					$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
159 159
 
160
-					$px1->draw($filenamenb,$fileurlnb);
160
+					$px1->draw($filenamenb, $fileurlnb);
161 161
 				}
162 162
 			}
163 163
 
164 164
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
165 165
 			if ($showtot)
166 166
 			{
167
-				$data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
167
+				$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
168 168
 
169 169
 				$filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
170 170
 				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png';
@@ -172,17 +172,17 @@  discard block
 block discarded – undo
172 172
 
173 173
 				$px2 = new DolGraph();
174 174
 				$mesg = $px2->isGraphKo();
175
-				if (! $mesg)
175
+				if (!$mesg)
176 176
 				{
177 177
 				    $langs->load("bills");
178 178
 
179 179
 					$px2->SetData($data2);
180 180
 					unset($data2);
181 181
 					$px2->SetPrecisionY(0);
182
-					$i=$startyear;$legend=array();
182
+					$i = $startyear; $legend = array();
183 183
 					while ($i <= $endyear)
184 184
 					{
185
-						$legend[]=$i;
185
+						$legend[] = $i;
186 186
 						$i++;
187 187
 					}
188 188
 					$px2->SetLegend($legend);
@@ -194,63 +194,63 @@  discard block
 block discarded – undo
194 194
 					$px2->SetHorizTickIncrement(1);
195 195
 					$px2->SetPrecisionY(0);
196 196
 					$px2->SetCssPrefix("cssboxes");
197
-					$px2->mode='depth';
197
+					$px2->mode = 'depth';
198 198
 					$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
199 199
 
200
-					$px2->draw($filenamenb,$fileurlnb);
200
+					$px2->draw($filenamenb, $fileurlnb);
201 201
 				}
202 202
 			}
203 203
 
204 204
 			if (empty($conf->use_javascript_ajax))
205 205
 			{
206 206
 				$langs->load("errors");
207
-				$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
207
+				$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
208 208
 			}
209 209
 
210
-			if (! $mesg)
210
+			if (!$mesg)
211 211
 			{
212
-				$stringtoshow='';
213
-				$stringtoshow.='<script type="text/javascript" language="javascript">
212
+				$stringtoshow = '';
213
+				$stringtoshow .= '<script type="text/javascript" language="javascript">
214 214
 					jQuery(document).ready(function() {
215 215
 						jQuery("#idsubimg'.$this->boxcode.'").click(function() {
216 216
 							jQuery("#idfilter'.$this->boxcode.'").toggle();
217 217
 						});
218 218
 					});
219 219
 					</script>';
220
-				$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
221
-				$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
222
-				$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
223
-				$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
224
-				$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfBillsByMonth");
225
-				$stringtoshow.=' &nbsp; ';
226
-				$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfBillsByMonthHT");
227
-				$stringtoshow.='<br>';
228
-				$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
229
-				$stringtoshow.='<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"),'refresh.png','','',1).'">';
230
-				$stringtoshow.='</form>';
231
-				$stringtoshow.='</div>';
220
+				$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
221
+				$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
222
+				$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
223
+				$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
224
+				$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfBillsByMonth");
225
+				$stringtoshow .= ' &nbsp; ';
226
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfBillsByMonthHT");
227
+				$stringtoshow .= '<br>';
228
+				$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
229
+				$stringtoshow .= '<input type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
230
+				$stringtoshow .= '</form>';
231
+				$stringtoshow .= '</div>';
232 232
 				if ($shownb && $showtot)
233 233
 				{
234
-					$stringtoshow.='<div class="fichecenter">';
235
-					$stringtoshow.='<div class="fichehalfleft">';
234
+					$stringtoshow .= '<div class="fichecenter">';
235
+					$stringtoshow .= '<div class="fichehalfleft">';
236 236
 				}
237
-				if ($shownb) $stringtoshow.=$px1->show();
237
+				if ($shownb) $stringtoshow .= $px1->show();
238 238
 				if ($shownb && $showtot)
239 239
 				{
240
-					$stringtoshow.='</div>';
241
-					$stringtoshow.='<div class="fichehalfright">';
240
+					$stringtoshow .= '</div>';
241
+					$stringtoshow .= '<div class="fichehalfright">';
242 242
 				}
243
-				if ($showtot) $stringtoshow.=$px2->show();
243
+				if ($showtot) $stringtoshow .= $px2->show();
244 244
 				if ($shownb && $showtot)
245 245
 				{
246
-					$stringtoshow.='</div>';
247
-					$stringtoshow.='</div>';
246
+					$stringtoshow .= '</div>';
247
+					$stringtoshow .= '</div>';
248 248
 				}
249
-				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
249
+				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"', 'textnoformat'=>$stringtoshow);
250 250
 			}
251 251
 			else
252 252
 			{
253
-				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
253
+				$this->info_box_contents[0][0] = array('td' => 'align="left" class="nohover"',
254 254
     	        										'maxlength'=>500,
255 255
 	            										'text' => $mesg);
256 256
 			}
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 *  @param	int		$nooutput	No print, only return string
273 273
 	 *	@return	string
274 274
 	 */
275
-    function showBox($head = null, $contents = null, $nooutput=0)
275
+    function showBox($head = null, $contents = null, $nooutput = 0)
276 276
     {
277 277
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
278 278
 	}
Please login to merge, or discard this patch.
Braces   +34 added lines, -16 removed lines patch added patch discarded remove patch
@@ -86,8 +86,13 @@  discard block
 block discarded – undo
86 86
 		$dir=''; 	// We don't need a path because image file will not be saved into disk
87 87
 		$prefix='';
88 88
 		$socid=0;
89
-		if ($user->societe_id) $socid=$user->societe_id;
90
-		if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-';	// If user has no permission to see all, output dir is specific to user
89
+		if ($user->societe_id) {
90
+			$socid=$user->societe_id;
91
+		}
92
+		if (! $user->rights->societe->client->voir || $socid) {
93
+			$prefix.='private-'.$user->id.'-';
94
+		}
95
+		// If user has no permission to see all, output dir is specific to user
91 96
 
92 97
 		if ($user->rights->facture->lire)
93 98
 		{
@@ -103,17 +108,20 @@  discard block
 block discarded – undo
103 108
 				$endyear=GETPOST($param_year,'int');
104 109
 				$shownb=GETPOST($param_shownb,'alpha');
105 110
 				$showtot=GETPOST($param_showtot,'alpha');
106
-			}
107
-			else
111
+			} else
108 112
 			{
109 113
 				$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
110 114
 				$endyear=$tmparray['year'];
111 115
 				$shownb=$tmparray['shownb'];
112 116
 				$showtot=$tmparray['showtot'];
113 117
 			}
114
-			if (empty($shownb) && empty($showtot)) $showtot=1;
118
+			if (empty($shownb) && empty($showtot)) {
119
+				$showtot=1;
120
+			}
115 121
 			$nowarray=dol_getdate(dol_now(),true);
116
-			if (empty($endyear)) $endyear=$nowarray['year'];
122
+			if (empty($endyear)) {
123
+				$endyear=$nowarray['year'];
124
+			}
117 125
 			$startyear=$endyear-1;
118 126
 			$mode='customer';
119 127
 			$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
@@ -127,8 +135,12 @@  discard block
 block discarded – undo
127 135
 				$data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
128 136
 
129 137
 				$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
130
-				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png';
131
-				if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$endyear.'.png';
138
+				if ($mode == 'customer') {
139
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png';
140
+				}
141
+				if ($mode == 'supplier') {
142
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$endyear.'.png';
143
+				}
132 144
 
133 145
 				$px1 = new DolGraph();
134 146
 				$mesg = $px1->isGraphKo();
@@ -167,8 +179,12 @@  discard block
 block discarded – undo
167 179
 				$data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
168 180
 
169 181
 				$filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
170
-				if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png';
171
-				if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-'.$endyear.'.png';
182
+				if ($mode == 'customer') {
183
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png';
184
+				}
185
+				if ($mode == 'supplier') {
186
+					$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-'.$endyear.'.png';
187
+				}
172 188
 
173 189
 				$px2 = new DolGraph();
174 190
 				$mesg = $px2->isGraphKo();
@@ -234,29 +250,31 @@  discard block
 block discarded – undo
234 250
 					$stringtoshow.='<div class="fichecenter">';
235 251
 					$stringtoshow.='<div class="fichehalfleft">';
236 252
 				}
237
-				if ($shownb) $stringtoshow.=$px1->show();
253
+				if ($shownb) {
254
+					$stringtoshow.=$px1->show();
255
+				}
238 256
 				if ($shownb && $showtot)
239 257
 				{
240 258
 					$stringtoshow.='</div>';
241 259
 					$stringtoshow.='<div class="fichehalfright">';
242 260
 				}
243
-				if ($showtot) $stringtoshow.=$px2->show();
261
+				if ($showtot) {
262
+					$stringtoshow.=$px2->show();
263
+				}
244 264
 				if ($shownb && $showtot)
245 265
 				{
246 266
 					$stringtoshow.='</div>';
247 267
 					$stringtoshow.='</div>';
248 268
 				}
249 269
 				$this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
250
-			}
251
-			else
270
+			} else
252 271
 			{
253 272
 				$this->info_box_contents[0][0] = array(	'td' => 'align="left" class="nohover"',
254 273
     	        										'maxlength'=>500,
255 274
 	            										'text' => $mesg);
256 275
 			}
257 276
 
258
-		}
259
-		else {
277
+		} else {
260 278
 			$this->info_box_contents[0][0] = array(
261 279
 			    'td' => 'align="left" class="nohover opacitymedium"',
262 280
                 'text' => $langs->trans("ReadPermissionNotAllowed")
Please login to merge, or discard this patch.