Passed
Push — master ( 222e44...208bd5 )
by Alxarafe
31:22
created
dolibarr/htdocs/core/boxes/box_contracts.php 3 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -70,67 +70,67 @@  discard block
 block discarded – undo
70 70
      */
71 71
     function loadBox($max=5)
72 72
     {
73
-    	global $user, $langs, $db, $conf;
73
+        global $user, $langs, $db, $conf;
74 74
 
75
-    	$this->max=$max;
75
+        $this->max=$max;
76 76
 
77
-    	include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
77
+        include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
78 78
 
79
-    	$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
79
+        $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
80 80
 
81
-    	if ($user->rights->contrat->lire)
82
-    	{
83
-        	$contractstatic=new Contrat($db);
84
-        	$thirdpartytmp=new Societe($db);
81
+        if ($user->rights->contrat->lire)
82
+        {
83
+            $contractstatic=new Contrat($db);
84
+            $thirdpartytmp=new Societe($db);
85 85
 
86
-    	    $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
87
-    		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
88
-    		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
89
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
90
-    		$sql.= " WHERE c.fk_soc = s.rowid";
91
-    		$sql.= " AND c.entity = ".$conf->entity;
92
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
93
-    		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
94
-    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
95
-    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
96
-    		$sql.= $db->plimit($max, 0);
86
+            $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
87
+            $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
88
+            $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
89
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
90
+            $sql.= " WHERE c.fk_soc = s.rowid";
91
+            $sql.= " AND c.entity = ".$conf->entity;
92
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
93
+            if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
94
+            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
95
+            else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
96
+            $sql.= $db->plimit($max, 0);
97 97
 
98
-    		$resql = $db->query($sql);
99
-    		if ($resql)
100
-    		{
101
-    			$num = $db->num_rows($resql);
102
-    			$now=dol_now();
98
+            $resql = $db->query($sql);
99
+            if ($resql)
100
+            {
101
+                $num = $db->num_rows($resql);
102
+                $now=dol_now();
103 103
 
104
-    			$line = 0;
104
+                $line = 0;
105 105
 
106
-    			$langs->load("contracts");
106
+                $langs->load("contracts");
107 107
 
108 108
                 while ($line < $num)
109 109
                 {
110
-    				$objp = $db->fetch_object($resql);
111
-
112
-    				$datec=$db->jdate($objp->datec);
113
-    				$dateterm=$db->jdate($objp->fin_validite);
114
-    				$dateclose=$db->jdate($objp->date_cloture);
115
-    				$late = '';
116
-
117
-    				$contractstatic->statut=$objp->fk_statut;
118
-    				$contractstatic->id=$objp->rowid;
119
-    				$contractstatic->ref=$objp->ref;
120
-    				$result=$contractstatic->fetch_lines();
121
-
122
-    				$thirdpartytmp->name = $objp->name;
123
-    				$thirdpartytmp->id = $objp->socid;
124
-    				$thirdpartytmp->email = $objp->email;
125
-    				$thirdpartytmp->client = $objp->client;
126
-    				$thirdpartytmp->fournisseur = $objp->fournisseur;
127
-    				$thirdpartytmp->code_client = $objp->code_client;
128
-    				$thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
129
-    				$thirdpartytmp->code_compta = $objp->code_compta;
130
-    				$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
131
-
132
-    				// fin_validite is no more on contract but on services
133
-    				// if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
110
+                    $objp = $db->fetch_object($resql);
111
+
112
+                    $datec=$db->jdate($objp->datec);
113
+                    $dateterm=$db->jdate($objp->fin_validite);
114
+                    $dateclose=$db->jdate($objp->date_cloture);
115
+                    $late = '';
116
+
117
+                    $contractstatic->statut=$objp->fk_statut;
118
+                    $contractstatic->id=$objp->rowid;
119
+                    $contractstatic->ref=$objp->ref;
120
+                    $result=$contractstatic->fetch_lines();
121
+
122
+                    $thirdpartytmp->name = $objp->name;
123
+                    $thirdpartytmp->id = $objp->socid;
124
+                    $thirdpartytmp->email = $objp->email;
125
+                    $thirdpartytmp->client = $objp->client;
126
+                    $thirdpartytmp->fournisseur = $objp->fournisseur;
127
+                    $thirdpartytmp->code_client = $objp->code_client;
128
+                    $thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
129
+                    $thirdpartytmp->code_compta = $objp->code_compta;
130
+                    $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
131
+
132
+                    // fin_validite is no more on contract but on services
133
+                    // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
134 134
 
135 135
                     $this->info_box_contents[$line][] = array(
136 136
                         'td' => '',
@@ -181,14 +181,14 @@  discard block
 block discarded – undo
181 181
         }
182 182
     }
183 183
 
184
-	/**
185
-	 *	Method to show box
186
-	 *
187
-	 *	@param	array	$head       Array with properties of box title
188
-	 *	@param  array	$contents   Array with properties of box lines
189
-	 *  @param	int		$nooutput	No print, only return string
190
-	 *	@return	string
191
-	 */
184
+    /**
185
+     *	Method to show box
186
+     *
187
+     *	@param	array	$head       Array with properties of box title
188
+     *	@param  array	$contents   Array with properties of box lines
189
+     *  @param	int		$nooutput	No print, only return string
190
+     *	@return	string
191
+     */
192 192
     function showBox($head = null, $contents = null, $nooutput=0)
193 193
     {
194 194
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
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
     /**
40 40
      * @var DoliDB Database handler.
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
      *  @param  DoliDB  $db         Database handler
54 54
      *  @param  string  $param      More parameters
55 55
      */
56
-    function __construct($db,$param)
56
+    function __construct($db, $param)
57 57
     {
58 58
         global $user;
59 59
 
60
-        $this->db=$db;
60
+        $this->db = $db;
61 61
 
62
-        $this->hidden=! ($user->rights->contrat->lire);
62
+        $this->hidden = !($user->rights->contrat->lire);
63 63
     }
64 64
 
65 65
     /**
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
      *  @param	int		$max        Maximum number of records to load
69 69
      *  @return	void
70 70
      */
71
-    function loadBox($max=5)
71
+    function loadBox($max = 5)
72 72
     {
73 73
     	global $user, $langs, $db, $conf;
74 74
 
75
-    	$this->max=$max;
75
+    	$this->max = $max;
76 76
 
77 77
     	include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
78 78
 
79
-    	$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts",$max));
79
+    	$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max));
80 80
 
81 81
     	if ($user->rights->contrat->lire)
82 82
     	{
83
-        	$contractstatic=new Contrat($db);
84
-        	$thirdpartytmp=new Societe($db);
83
+        	$contractstatic = new Contrat($db);
84
+        	$thirdpartytmp = new Societe($db);
85 85
 
86 86
     	    $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
87
-    		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
88
-    		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
89
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
90
-    		$sql.= " WHERE c.fk_soc = s.rowid";
91
-    		$sql.= " AND c.entity = ".$conf->entity;
92
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
93
-    		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
94
-    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
95
-    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
96
-    		$sql.= $db->plimit($max, 0);
87
+    		$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
88
+    		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
89
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
90
+    		$sql .= " WHERE c.fk_soc = s.rowid";
91
+    		$sql .= " AND c.entity = ".$conf->entity;
92
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
93
+    		if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
94
+    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC ";
95
+    		else $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
96
+    		$sql .= $db->plimit($max, 0);
97 97
 
98 98
     		$resql = $db->query($sql);
99 99
     		if ($resql)
100 100
     		{
101 101
     			$num = $db->num_rows($resql);
102
-    			$now=dol_now();
102
+    			$now = dol_now();
103 103
 
104 104
     			$line = 0;
105 105
 
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
                 {
110 110
     				$objp = $db->fetch_object($resql);
111 111
 
112
-    				$datec=$db->jdate($objp->datec);
113
-    				$dateterm=$db->jdate($objp->fin_validite);
114
-    				$dateclose=$db->jdate($objp->date_cloture);
112
+    				$datec = $db->jdate($objp->datec);
113
+    				$dateterm = $db->jdate($objp->fin_validite);
114
+    				$dateclose = $db->jdate($objp->date_cloture);
115 115
     				$late = '';
116 116
 
117
-    				$contractstatic->statut=$objp->fk_statut;
118
-    				$contractstatic->id=$objp->rowid;
119
-    				$contractstatic->ref=$objp->ref;
120
-    				$result=$contractstatic->fetch_lines();
117
+    				$contractstatic->statut = $objp->fk_statut;
118
+    				$contractstatic->id = $objp->rowid;
119
+    				$contractstatic->ref = $objp->ref;
120
+    				$result = $contractstatic->fetch_lines();
121 121
 
122 122
     				$thirdpartytmp->name = $objp->name;
123 123
     				$thirdpartytmp->id = $objp->socid;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
                     $this->info_box_contents[$line][] = array(
149 149
                         'td' => 'class="right"',
150
-                        'text' => dol_print_date($datec,'day'),
150
+                        'text' => dol_print_date($datec, 'day'),
151 151
                     );
152 152
 
153 153
                     $this->info_box_contents[$line][] = array(
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                     $line++;
160 160
                 }
161 161
 
162
-                if ($num==0)
162
+                if ($num == 0)
163 163
                     $this->info_box_contents[$line][0] = array(
164 164
                         'td' => 'align="center opacitymedium"',
165 165
                         'text'=>$langs->trans("NoRecordedContracts"),
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *  @param	int		$nooutput	No print, only return string
190 190
 	 *	@return	string
191 191
 	 */
192
-    function showBox($head = null, $contents = null, $nooutput=0)
192
+    function showBox($head = null, $contents = null, $nooutput = 0)
193 193
     {
194 194
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
195 195
     }
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -86,13 +86,22 @@  discard block
 block discarded – undo
86 86
     	    $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
87 87
     		$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
88 88
     		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
89
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
89
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) {
90
+    		    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
91
+    		}
90 92
     		$sql.= " WHERE c.fk_soc = s.rowid";
91 93
     		$sql.= " AND c.entity = ".$conf->entity;
92
-    		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
93
-    		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
94
-    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
95
-    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
94
+    		if (!$user->rights->societe->client->voir && !$user->societe_id) {
95
+    		    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
96
+    		}
97
+    		if($user->societe_id) {
98
+    		    $sql.= " AND s.rowid = ".$user->societe_id;
99
+    		}
100
+    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
101
+    		    $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
102
+    		} else {
103
+    		    $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
104
+    		}
96 105
     		$sql.= $db->plimit($max, 0);
97 106
 
98 107
     		$resql = $db->query($sql);
@@ -159,11 +168,12 @@  discard block
 block discarded – undo
159 168
                     $line++;
160 169
                 }
161 170
 
162
-                if ($num==0)
163
-                    $this->info_box_contents[$line][0] = array(
171
+                if ($num==0) {
172
+                                    $this->info_box_contents[$line][0] = array(
164 173
                         'td' => 'align="center opacitymedium"',
165 174
                         'text'=>$langs->trans("NoRecordedContracts"),
166 175
                     );
176
+                }
167 177
 
168 178
                 $db->free($resql);
169 179
             } else {
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/modules_boxes.php 3 patches
Indentation   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -33,186 +33,186 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" boxes
35 35
 {
36
-	/**
37
-	 * @var DoliDB Database handler
38
-	 */
39
-	public $db;
40
-
41
-	/**
42
-	 * @var string Error message
43
-	 */
44
-	public $error = '';
45
-
46
-	/**
47
-	 * @var int Maximum lines
48
-	 */
49
-	public $max = 5;
50
-
51
-	/**
52
-	 * @var int Condition to have widget enabled
53
-	 */
54
-	public $enabled=1;
55
-
56
-	/**
57
-	 * @var int Condition to have widget visible (in most cases, permissions)
58
-	 */
59
-	public $hidden=0;
60
-
61
-	/**
62
-	 * @var int Box definition database ID
63
-	 */
64
-	public $rowid;
65
-
66
-	/**
67
-	 * @var int ID
68
-	 * @deprecated Same as box_id?
69
-	 */
70
-	public $id;
71
-
72
-	/**
73
-	 * @var int Position?
74
-	 */
75
-	public $position;
76
-
77
-	/**
78
-	 * @var string Display order
79
-	 */
80
-	public $box_order;
81
-
82
-	/**
83
-	 * @var int User ID
84
-	 */
85
-	public $fk_user;
86
-
87
-	/**
88
-	 * @var string Source file
89
-	 */
90
-	public $sourcefile;
91
-
92
-	/**
93
-	 * @var string Class name
94
-	 */
95
-	public $class;
96
-
97
-	/**
98
-	 * @var string ID
99
-	 */
100
-	public $box_id;
101
-
102
-	/**
103
-	 * @var string Alphanumeric ID
104
-	 */
105
-	public $boxcode;
106
-
107
-	/**
108
-	 * @var string Note
109
-	 */
110
-	public $note;
111
-
112
-	/**
113
-	 * Constructor
114
-	 *
115
-	 * @param   DoliDB  $db     Database handler
36
+    /**
37
+     * @var DoliDB Database handler
38
+     */
39
+    public $db;
40
+
41
+    /**
42
+     * @var string Error message
43
+     */
44
+    public $error = '';
45
+
46
+    /**
47
+     * @var int Maximum lines
48
+     */
49
+    public $max = 5;
50
+
51
+    /**
52
+     * @var int Condition to have widget enabled
53
+     */
54
+    public $enabled=1;
55
+
56
+    /**
57
+     * @var int Condition to have widget visible (in most cases, permissions)
58
+     */
59
+    public $hidden=0;
60
+
61
+    /**
62
+     * @var int Box definition database ID
63
+     */
64
+    public $rowid;
65
+
66
+    /**
67
+     * @var int ID
68
+     * @deprecated Same as box_id?
69
+     */
70
+    public $id;
71
+
72
+    /**
73
+     * @var int Position?
74
+     */
75
+    public $position;
76
+
77
+    /**
78
+     * @var string Display order
79
+     */
80
+    public $box_order;
81
+
82
+    /**
83
+     * @var int User ID
84
+     */
85
+    public $fk_user;
86
+
87
+    /**
88
+     * @var string Source file
89
+     */
90
+    public $sourcefile;
91
+
92
+    /**
93
+     * @var string Class name
94
+     */
95
+    public $class;
96
+
97
+    /**
98
+     * @var string ID
99
+     */
100
+    public $box_id;
101
+
102
+    /**
103
+     * @var string Alphanumeric ID
104
+     */
105
+    public $boxcode;
106
+
107
+    /**
108
+     * @var string Note
109
+     */
110
+    public $note;
111
+
112
+    /**
113
+     * Constructor
114
+     *
115
+     * @param   DoliDB  $db     Database handler
116 116
      * @param   string  $param  More parameters
117
-	 */
118
-	function __construct($db,$param='')
119
-	{
120
-		$this->db=$db;
121
-	}
122
-
123
-	/**
124
-	 * Return last error message
125
-	 *
126
-	 * @return  string  Error message
127
-	 */
128
-	function error()
129
-	{
130
-		return $this->error;
131
-	}
132
-
133
-
134
-	/**
135
-	 * Load a box line from its rowid
136
-	 *
137
-	 * @param   int $rowid  Row id to load
138
-	 *
139
-	 * @return  int         <0 if KO, >0 if OK
140
-	 */
141
-	function fetch($rowid)
142
-	{
143
-		global $conf;
144
-
145
-		// Recupere liste des boites d'un user si ce dernier a sa propre liste
146
-		$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user";
147
-		$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b";
148
-		$sql.= " WHERE b.entity = ".$conf->entity;
149
-		$sql.= " AND b.rowid = ".$rowid;
150
-		dol_syslog(get_class($this)."::fetch rowid=".$rowid);
151
-
152
-		$resql = $this->db->query($sql);
153
-		if ($resql)
154
-		{
155
-			$obj = $this->db->fetch_object($resql);
156
-			if ($obj)
157
-			{
158
-				$this->rowid=$obj->rowid;
159
-				$this->box_id=$obj->box_id;
160
-				$this->position=$obj->position;
161
-				$this->box_order=$obj->box_order;
162
-				$this->fk_user=$obj->fk_user;
163
-				return 1;
164
-			}
165
-			else
166
-			{
167
-				return -1;
168
-			}
169
-		}
170
-		else
171
-		{
172
-			return -1;
173
-		}
174
-	}
175
-
176
-
177
-	/**
178
-	 * Standard method to get content of a box
179
-	 *
180
-	 * @param   array   $head       Array with properties of box title
181
-	 * @param   array   $contents   Array with properties of box lines
182
-	 *
183
-	 * @return  string
184
-	 */
185
-	function outputBox($head = null, $contents = null)
186
-	{
187
-		global $langs, $user, $conf;
188
-
189
-		// Trick to get result into a var from a function that makes print instead of return
190
-		// TODO Replace ob_start with param nooutput=1 into showBox
191
-		ob_start();
192
-		$result = $this->showBox($head, $contents);
193
-		$output = ob_get_contents();
194
-		ob_end_clean();
195
-
196
-		return $output;
197
-	}
198
-
199
-	/**
200
-	 * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
201
-	 *
202
-	 * @param   array   $head       Array with properties of box title
203
-	 * @param   array   $contents   Array with properties of box lines
204
-	 * @param	int		$nooutput	No print, only return string
205
-	 * @return  string
206
-	 */
207
-	function showBox($head = null, $contents = null, $nooutput=0)
208
-	{
209
-		global $langs, $user, $conf;
210
-
211
-		if (! empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n';    // Nothing done if hidden (for example when user has no permission)
117
+     */
118
+    function __construct($db,$param='')
119
+    {
120
+        $this->db=$db;
121
+    }
122
+
123
+    /**
124
+     * Return last error message
125
+     *
126
+     * @return  string  Error message
127
+     */
128
+    function error()
129
+    {
130
+        return $this->error;
131
+    }
132
+
133
+
134
+    /**
135
+     * Load a box line from its rowid
136
+     *
137
+     * @param   int $rowid  Row id to load
138
+     *
139
+     * @return  int         <0 if KO, >0 if OK
140
+     */
141
+    function fetch($rowid)
142
+    {
143
+        global $conf;
144
+
145
+        // Recupere liste des boites d'un user si ce dernier a sa propre liste
146
+        $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user";
147
+        $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b";
148
+        $sql.= " WHERE b.entity = ".$conf->entity;
149
+        $sql.= " AND b.rowid = ".$rowid;
150
+        dol_syslog(get_class($this)."::fetch rowid=".$rowid);
151
+
152
+        $resql = $this->db->query($sql);
153
+        if ($resql)
154
+        {
155
+            $obj = $this->db->fetch_object($resql);
156
+            if ($obj)
157
+            {
158
+                $this->rowid=$obj->rowid;
159
+                $this->box_id=$obj->box_id;
160
+                $this->position=$obj->position;
161
+                $this->box_order=$obj->box_order;
162
+                $this->fk_user=$obj->fk_user;
163
+                return 1;
164
+            }
165
+            else
166
+            {
167
+                return -1;
168
+            }
169
+        }
170
+        else
171
+        {
172
+            return -1;
173
+        }
174
+    }
175
+
176
+
177
+    /**
178
+     * Standard method to get content of a box
179
+     *
180
+     * @param   array   $head       Array with properties of box title
181
+     * @param   array   $contents   Array with properties of box lines
182
+     *
183
+     * @return  string
184
+     */
185
+    function outputBox($head = null, $contents = null)
186
+    {
187
+        global $langs, $user, $conf;
188
+
189
+        // Trick to get result into a var from a function that makes print instead of return
190
+        // TODO Replace ob_start with param nooutput=1 into showBox
191
+        ob_start();
192
+        $result = $this->showBox($head, $contents);
193
+        $output = ob_get_contents();
194
+        ob_end_clean();
195
+
196
+        return $output;
197
+    }
198
+
199
+    /**
200
+     * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
201
+     *
202
+     * @param   array   $head       Array with properties of box title
203
+     * @param   array   $contents   Array with properties of box lines
204
+     * @param	int		$nooutput	No print, only return string
205
+     * @return  string
206
+     */
207
+    function showBox($head = null, $contents = null, $nooutput=0)
208
+    {
209
+        global $langs, $user, $conf;
210
+
211
+        if (! empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n';    // Nothing done if hidden (for example when user has no permission)
212 212
 
213 213
         require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
214 214
 
215
-		$MAXLENGTHBOX=60;   // Mettre 0 pour pas de limite
215
+        $MAXLENGTHBOX=60;   // Mettre 0 pour pas de limite
216 216
 
217 217
         $cachetime = 900;   // 900 : 15mn
218 218
         $cachedir = DOL_DATA_ROOT.'/boxes/temp';
@@ -375,133 +375,133 @@  discard block
 block discarded – undo
375 375
         else print $out;
376 376
 
377 377
         return '';
378
-	}
379
-
380
-
381
-	/**
382
-	 *  Return list of widget. Function used by admin page htdoc/admin/widget.
383
-	 *  List is sorted by widget filename so by priority to run.
384
-	 *
385
-	 *  @param	array	$forcedirwidget		null=All default directories. This parameter is used by modulebuilder module only.
386
-	 * 	@return	array						Array list of widget
387
-	 */
388
-	static function getWidgetsList($forcedirwidget=null)
389
-	{
390
-		global $conf, $langs, $db;
391
-
392
-		$files = array();
393
-		$fullpath = array();
394
-		$relpath = array();
395
-		$iscoreorexternal = array();
396
-		$modules = array();
397
-		$orders = array();
398
-		$i = 0;
399
-
400
-		$dirwidget=array_merge(array('/core/boxes/'));
401
-		if (is_array($forcedirwidget))
402
-		{
403
-			$dirwidget=$forcedirwidget;
404
-		}
405
-
406
-		foreach($dirwidget as $reldir)
407
-		{
408
-			$dir=dol_buildpath($reldir,0);
409
-			$newdir=dol_osencode($dir);
410
-
411
-			// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
412
-			if (! is_dir($newdir)) continue;
413
-
414
-			$handle=opendir($newdir);
415
-			if (is_resource($handle))
416
-			{
417
-				while (($file = readdir($handle))!==false)
418
-				{
419
-					if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/',$file,$reg))
420
-					{
421
-						if (preg_match('/\.back$/',$file)) continue;
422
-
423
-						$part1=$reg[1];
424
-
425
-						$modName = ucfirst($reg[1]);
426
-						//print "file=$file"; print "modName=$modName"; exit;
427
-						if (in_array($modName,$modules))
428
-						{
429
-							$langs->load("errors");
430
-							print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget",$modName,"").'</div>';
431
-						}
432
-						else
433
-						{
434
-							try {
435
-								include_once $newdir.'/'.$file;
436
-							}
437
-							catch(Exception $e)
438
-							{
439
-								print $e->getMessage();
440
-							}
441
-						}
442
-
443
-						$files[$i] = $file;
444
-						$fullpath[$i] = $dir.'/'.$file;
445
-						$relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file;
446
-						$iscoreorexternal[$i] = ($reldir == '/core/boxes/'?'internal':'external');
447
-						$modules[$i] = $modName;
448
-						$orders[$i] = $part1;   // Set sort criteria value
449
-
450
-						$i++;
451
-					}
452
-				}
453
-				closedir($handle);
454
-			}
455
-		}
456
-
457
-		asort($orders);
458
-
459
-		$widget = array();
460
-		$j = 0;
461
-
462
-		// Loop on each widget
463
-		foreach ($orders as $key => $value)
464
-		{
465
-			$modName = $modules[$key];
466
-			if (empty($modName)) continue;
467
-
468
-			if (! class_exists($modName))
469
-			{
470
-				print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."<br>\n";
471
-				continue;
472
-			}
473
-
474
-			$objMod = new $modName($db);
475
-			if (is_object($objMod))
476
-			{
477
-				// Define disabledbyname and disabledbymodule
478
-				$disabledbyname=0;
479
-				$module='';
480
-
481
-				// Check if widget file is disabled by name
482
-				if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1;
483
-
484
-				// We set info of modules
485
-				$widget[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic');
486
-				$widget[$j]['file'] = $files[$key];
487
-				$widget[$j]['fullpath'] = $fullpath[$key];
488
-				$widget[$j]['relpath'] = $relpath[$key];
489
-				$widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
490
-				//$widget[$j]['version'] = $objMod->getVersion();
491
-				$widget[$j]['status'] = img_picto($langs->trans("Active"),'tick');
492
-				if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = '';
493
-
494
-				$text ='<b>'.$langs->trans("Description").':</b><br>';
495
-				$text.=$objMod->boxlabel.'<br>';
496
-				$text.='<br><b>'.$langs->trans("Status").':</b><br>';
497
-				if ($disabledbymodule == 2) $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'<br>';
498
-
499
-				$widget[$j]['info'] = $text;
500
-			}
501
-			$j++;
502
-		}
503
-		return $widget;
504
-	}
378
+    }
379
+
380
+
381
+    /**
382
+     *  Return list of widget. Function used by admin page htdoc/admin/widget.
383
+     *  List is sorted by widget filename so by priority to run.
384
+     *
385
+     *  @param	array	$forcedirwidget		null=All default directories. This parameter is used by modulebuilder module only.
386
+     * 	@return	array						Array list of widget
387
+     */
388
+    static function getWidgetsList($forcedirwidget=null)
389
+    {
390
+        global $conf, $langs, $db;
391
+
392
+        $files = array();
393
+        $fullpath = array();
394
+        $relpath = array();
395
+        $iscoreorexternal = array();
396
+        $modules = array();
397
+        $orders = array();
398
+        $i = 0;
399
+
400
+        $dirwidget=array_merge(array('/core/boxes/'));
401
+        if (is_array($forcedirwidget))
402
+        {
403
+            $dirwidget=$forcedirwidget;
404
+        }
405
+
406
+        foreach($dirwidget as $reldir)
407
+        {
408
+            $dir=dol_buildpath($reldir,0);
409
+            $newdir=dol_osencode($dir);
410
+
411
+            // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
412
+            if (! is_dir($newdir)) continue;
413
+
414
+            $handle=opendir($newdir);
415
+            if (is_resource($handle))
416
+            {
417
+                while (($file = readdir($handle))!==false)
418
+                {
419
+                    if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/',$file,$reg))
420
+                    {
421
+                        if (preg_match('/\.back$/',$file)) continue;
422
+
423
+                        $part1=$reg[1];
424
+
425
+                        $modName = ucfirst($reg[1]);
426
+                        //print "file=$file"; print "modName=$modName"; exit;
427
+                        if (in_array($modName,$modules))
428
+                        {
429
+                            $langs->load("errors");
430
+                            print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget",$modName,"").'</div>';
431
+                        }
432
+                        else
433
+                        {
434
+                            try {
435
+                                include_once $newdir.'/'.$file;
436
+                            }
437
+                            catch(Exception $e)
438
+                            {
439
+                                print $e->getMessage();
440
+                            }
441
+                        }
442
+
443
+                        $files[$i] = $file;
444
+                        $fullpath[$i] = $dir.'/'.$file;
445
+                        $relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file;
446
+                        $iscoreorexternal[$i] = ($reldir == '/core/boxes/'?'internal':'external');
447
+                        $modules[$i] = $modName;
448
+                        $orders[$i] = $part1;   // Set sort criteria value
449
+
450
+                        $i++;
451
+                    }
452
+                }
453
+                closedir($handle);
454
+            }
455
+        }
456
+
457
+        asort($orders);
458
+
459
+        $widget = array();
460
+        $j = 0;
461
+
462
+        // Loop on each widget
463
+        foreach ($orders as $key => $value)
464
+        {
465
+            $modName = $modules[$key];
466
+            if (empty($modName)) continue;
467
+
468
+            if (! class_exists($modName))
469
+            {
470
+                print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."<br>\n";
471
+                continue;
472
+            }
473
+
474
+            $objMod = new $modName($db);
475
+            if (is_object($objMod))
476
+            {
477
+                // Define disabledbyname and disabledbymodule
478
+                $disabledbyname=0;
479
+                $module='';
480
+
481
+                // Check if widget file is disabled by name
482
+                if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1;
483
+
484
+                // We set info of modules
485
+                $widget[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic');
486
+                $widget[$j]['file'] = $files[$key];
487
+                $widget[$j]['fullpath'] = $fullpath[$key];
488
+                $widget[$j]['relpath'] = $relpath[$key];
489
+                $widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
490
+                //$widget[$j]['version'] = $objMod->getVersion();
491
+                $widget[$j]['status'] = img_picto($langs->trans("Active"),'tick');
492
+                if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = '';
493
+
494
+                $text ='<b>'.$langs->trans("Description").':</b><br>';
495
+                $text.=$objMod->boxlabel.'<br>';
496
+                $text.='<br><b>'.$langs->trans("Status").':</b><br>';
497
+                if ($disabledbymodule == 2) $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'<br>';
498
+
499
+                $widget[$j]['info'] = $text;
500
+            }
501
+            $j++;
502
+        }
503
+        return $widget;
504
+    }
505 505
 }
506 506
 
507 507
 
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @var int Condition to have widget enabled
53 53
 	 */
54
-	public $enabled=1;
54
+	public $enabled = 1;
55 55
 
56 56
 	/**
57 57
 	 * @var int Condition to have widget visible (in most cases, permissions)
58 58
 	 */
59
-	public $hidden=0;
59
+	public $hidden = 0;
60 60
 
61 61
 	/**
62 62
 	 * @var int Box definition database ID
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 * @param   DoliDB  $db     Database handler
116 116
      * @param   string  $param  More parameters
117 117
 	 */
118
-	function __construct($db,$param='')
118
+	function __construct($db, $param = '')
119 119
 	{
120
-		$this->db=$db;
120
+		$this->db = $db;
121 121
 	}
122 122
 
123 123
 	/**
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Recupere liste des boites d'un user si ce dernier a sa propre liste
146 146
 		$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user";
147
-		$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b";
148
-		$sql.= " WHERE b.entity = ".$conf->entity;
149
-		$sql.= " AND b.rowid = ".$rowid;
147
+		$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b";
148
+		$sql .= " WHERE b.entity = ".$conf->entity;
149
+		$sql .= " AND b.rowid = ".$rowid;
150 150
 		dol_syslog(get_class($this)."::fetch rowid=".$rowid);
151 151
 
152 152
 		$resql = $this->db->query($sql);
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 			$obj = $this->db->fetch_object($resql);
156 156
 			if ($obj)
157 157
 			{
158
-				$this->rowid=$obj->rowid;
159
-				$this->box_id=$obj->box_id;
160
-				$this->position=$obj->position;
161
-				$this->box_order=$obj->box_order;
162
-				$this->fk_user=$obj->fk_user;
158
+				$this->rowid = $obj->rowid;
159
+				$this->box_id = $obj->box_id;
160
+				$this->position = $obj->position;
161
+				$this->box_order = $obj->box_order;
162
+				$this->fk_user = $obj->fk_user;
163 163
 				return 1;
164 164
 			}
165 165
 			else
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 	 * @param	int		$nooutput	No print, only return string
205 205
 	 * @return  string
206 206
 	 */
207
-	function showBox($head = null, $contents = null, $nooutput=0)
207
+	function showBox($head = null, $contents = null, $nooutput = 0)
208 208
 	{
209 209
 		global $langs, $user, $conf;
210 210
 
211
-		if (! empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n';    // Nothing done if hidden (for example when user has no permission)
211
+		if (!empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n'; // Nothing done if hidden (for example when user has no permission)
212 212
 
213
-        require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
213
+        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
214 214
 
215
-		$MAXLENGTHBOX=60;   // Mettre 0 pour pas de limite
215
+		$MAXLENGTHBOX = 60; // Mettre 0 pour pas de limite
216 216
 
217
-        $cachetime = 900;   // 900 : 15mn
217
+        $cachetime = 900; // 900 : 15mn
218 218
         $cachedir = DOL_DATA_ROOT.'/boxes/temp';
219 219
         $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'.cache';
220 220
         $filename = '/box-'.$fileid;
@@ -225,150 +225,150 @@  discard block
 block discarded – undo
225 225
             dol_syslog(get_class($this).'::showBox');
226 226
 
227 227
             // Define nbcol and nblines of the box to show
228
-            $nbcol=0;
229
-            if (isset($contents[0])) $nbcol=count($contents[0]);
230
-            $nblines=count($contents);
228
+            $nbcol = 0;
229
+            if (isset($contents[0])) $nbcol = count($contents[0]);
230
+            $nblines = count($contents);
231 231
 
232
-            $out.= "\n<!-- Box ".get_class($this)." start -->\n";
232
+            $out .= "\n<!-- Box ".get_class($this)." start -->\n";
233 233
 
234
-            $out.= '<div class="box boxdraggable" id="boxto_'.$this->box_id.'">'."\n";
234
+            $out .= '<div class="box boxdraggable" id="boxto_'.$this->box_id.'">'."\n";
235 235
 
236
-            if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']) || $nblines)
236
+            if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines)
237 237
             {
238
-                $out.= '<table summary="boxtable'.$this->box_id.'" width="100%" class="noborder boxtable">'."\n";
238
+                $out .= '<table summary="boxtable'.$this->box_id.'" width="100%" class="noborder boxtable">'."\n";
239 239
             }
240 240
 
241 241
             // Show box title
242
-            if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']))
242
+            if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']))
243 243
             {
244
-                $out.= '<tr class="liste_titre box_titre">';
245
-                $out.= '<td';
246
-                if ($nbcol > 0) { $out.= ' colspan="'.$nbcol.'"'; }
247
-                $out.= '>';
244
+                $out .= '<tr class="liste_titre box_titre">';
245
+                $out .= '<td';
246
+                if ($nbcol > 0) { $out .= ' colspan="'.$nbcol.'"'; }
247
+                $out .= '>';
248 248
                 if ($conf->use_javascript_ajax)
249 249
                 {
250
-                    $out.= '<table summary="" class="nobordernopadding" width="100%"><tr><td class="tdoverflowmax150 maxwidth150onsmartphone">';
250
+                    $out .= '<table summary="" class="nobordernopadding" width="100%"><tr><td class="tdoverflowmax150 maxwidth150onsmartphone">';
251 251
                 }
252
-                if (! empty($head['text']))
252
+                if (!empty($head['text']))
253 253
                 {
254
-                    $s=dol_trunc($head['text'],isset($head['limit'])?$head['limit']:$MAXLENGTHBOX);
255
-                    $out.= $s;
254
+                    $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX);
255
+                    $out .= $s;
256 256
                 }
257
-                $out.= '</td>';
257
+                $out .= '</td>';
258 258
 
259
-                if (! empty($conf->use_javascript_ajax))
259
+                if (!empty($conf->use_javascript_ajax))
260 260
                 {
261
-                    $sublink='';
262
-                    if (! empty($head['sublink']))  $sublink.= '<a href="'.$head['sublink'].'"'.(empty($head['target'])?'':' target="'.$head['target'].'"').'>';
263
-                    if (! empty($head['subpicto'])) $sublink.= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium '.(empty($head['subclass'])?'':$head['subclass']).'" id="idsubimg'.$this->boxcode.'"');
264
-                    if (! empty($head['sublink']))  $sublink.= '</a>';
261
+                    $sublink = '';
262
+                    if (!empty($head['sublink']))  $sublink .= '<a href="'.$head['sublink'].'"'.(empty($head['target']) ? '' : ' target="'.$head['target'].'"').'>';
263
+                    if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"');
264
+                    if (!empty($head['sublink']))  $sublink .= '</a>';
265 265
 
266
-                    $out.= '<td class="nocellnopadd boxclose right nowraponall">';
267
-                    $out.=$sublink;
266
+                    $out .= '<td class="nocellnopadd boxclose right nowraponall">';
267
+                    $out .= $sublink;
268 268
                     // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
269
-                    $out.= img_picto($langs->trans("MoveBox",$this->box_id),'grip_title','class="opacitymedium boxhandle hideonsmartphone cursormove"');
270
-                    $out.= img_picto($langs->trans("CloseBox",$this->box_id),'close_title','class="opacitymedium boxclose cursorpointer" rel="x:y" id="imgclose'.$this->box_id.'"');
271
-                    $label=$head['text'];
269
+                    $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove"');
270
+                    $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer" rel="x:y" id="imgclose'.$this->box_id.'"');
271
+                    $label = $head['text'];
272 272
                     //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')';
273
-                    if (! empty($head['graph'])) $label.=' <span class="opacitymedium fa fa-bar-chart"></span>';
274
-                    $out.= '<input type="hidden" id="boxlabelentry'.$this->box_id.'" value="'.dol_escape_htmltag($label).'">';
275
-                    $out.= '</td></tr></table>';
273
+                    if (!empty($head['graph'])) $label .= ' <span class="opacitymedium fa fa-bar-chart"></span>';
274
+                    $out .= '<input type="hidden" id="boxlabelentry'.$this->box_id.'" value="'.dol_escape_htmltag($label).'">';
275
+                    $out .= '</td></tr></table>';
276 276
                 }
277 277
 
278
-                $out.= "</tr>\n";
278
+                $out .= "</tr>\n";
279 279
             }
280 280
 
281 281
             // Show box lines
282 282
             if ($nblines)
283 283
             {
284 284
                 // Loop on each record
285
-                for ($i=0, $n=$nblines; $i < $n; $i++)
285
+                for ($i = 0, $n = $nblines; $i < $n; $i++)
286 286
                 {
287 287
                     if (isset($contents[$i]))
288 288
                     {
289 289
                         // TR
290
-                        if (isset($contents[$i][0]['tr'])) $out.= '<tr '.$contents[$i][0]['tr'].'>';
291
-                        else $out.= '<tr class="oddeven">';
290
+                        if (isset($contents[$i][0]['tr'])) $out .= '<tr '.$contents[$i][0]['tr'].'>';
291
+                        else $out .= '<tr class="oddeven">';
292 292
 
293 293
                         // Loop on each TD
294
-                        $nbcolthisline=count($contents[$i]);
295
-                        for ($j=0; $j < $nbcolthisline; $j++) {
294
+                        $nbcolthisline = count($contents[$i]);
295
+                        for ($j = 0; $j < $nbcolthisline; $j++) {
296 296
                             // Define tdparam
297
-                            $tdparam='';
298
-                            if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td'];
299
-
300
-                            $text=isset($contents[$i][$j]['text'])?$contents[$i][$j]['text']:'';
301
-                            $textwithnotags=preg_replace('/<([^>]+)>/i','',$text);
302
-                            $text2=isset($contents[$i][$j]['text2'])?$contents[$i][$j]['text2']:'';
303
-                            $text2withnotags=preg_replace('/<([^>]+)>/i','',$text2);
304
-                            $textnoformat=isset($contents[$i][$j]['textnoformat'])?$contents[$i][$j]['textnoformat']:'';
297
+                            $tdparam = '';
298
+                            if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td'];
299
+
300
+                            $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : '';
301
+                            $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text);
302
+                            $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : '';
303
+                            $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2);
304
+                            $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : '';
305 305
                             //$out.= "xxx $textwithnotags y";
306
-                            if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip']="";
307
-                            $tooltip=isset($contents[$i][$j]['tooltip'])?$contents[$i][$j]['tooltip']:'';
306
+                            if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = "";
307
+                            $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : '';
308 308
 
309
-                            $out.= '<td'.$tdparam.'>'."\n";
309
+                            $out .= '<td'.$tdparam.'>'."\n";
310 310
 
311 311
                             // Url
312
-                            if (! empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo']))
312
+                            if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo']))
313 313
                             {
314
-                                $out.= '<a href="'.$contents[$i][$j]['url'].'"';
314
+                                $out .= '<a href="'.$contents[$i][$j]['url'].'"';
315 315
                                 if (!empty($tooltip)) {
316 316
                                     $out .= ' title="'.dol_escape_htmltag($langs->trans("Show").' '.$tooltip, 1).'" class="classfortooltip"';
317 317
                                 }
318 318
                                 //$out.= ' alt="'.$textwithnotags.'"';      // Pas de alt sur un "<a href>"
319
-                                $out.= isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':'';
320
-                                $out.= '>';
319
+                                $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : '';
320
+                                $out .= '>';
321 321
                             }
322 322
 
323 323
                             // Logo
324
-                            if (! empty($contents[$i][$j]['logo']))
324
+                            if (!empty($contents[$i][$j]['logo']))
325 325
                             {
326
-                                $logo=preg_replace("/^object_/i","",$contents[$i][$j]['logo']);
327
-                                $out.= '<a href="'.$contents[$i][$j]['url'].'">';
328
-                                $out.= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"');
326
+                                $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']);
327
+                                $out .= '<a href="'.$contents[$i][$j]['url'].'">';
328
+                                $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"');
329 329
                             }
330 330
 
331
-                            $maxlength=$MAXLENGTHBOX;
332
-                            if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
331
+                            $maxlength = $MAXLENGTHBOX;
332
+                            if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength'];
333 333
 
334
-                            if ($maxlength) $textwithnotags=dol_trunc($textwithnotags,$maxlength);
335
-                            if (preg_match('/^<img/i',$text) || preg_match('/^<div/i',$text) || ! empty($contents[$i][$j]['asis'])) $out.= $text;   // show text with no html cleaning
336
-                            else $out.= $textwithnotags;                // show text with html cleaning
334
+                            if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength);
335
+                            if (preg_match('/^<img/i', $text) || preg_match('/^<div/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning
336
+                            else $out .= $textwithnotags; // show text with html cleaning
337 337
 
338 338
                             // End Url
339
-                            if (! empty($contents[$i][$j]['url'])) $out.= '</a>';
339
+                            if (!empty($contents[$i][$j]['url'])) $out .= '</a>';
340 340
 
341
-                            if (preg_match('/^<img/i',$text2) || preg_match('/^<div/i',$text2) || ! empty($contents[$i][$j]['asis2'])) $out.= $text2; // show text with no html cleaning
342
-                            else $out.= $text2withnotags;               // show text with html cleaning
341
+                            if (preg_match('/^<img/i', $text2) || preg_match('/^<div/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning
342
+                            else $out .= $text2withnotags; // show text with html cleaning
343 343
 
344
-                            if (! empty($textnoformat)) $out.= "\n".$textnoformat."\n";
344
+                            if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n";
345 345
 
346
-                            $out.= "</td>\n";
346
+                            $out .= "</td>\n";
347 347
                         }
348 348
 
349
-                        $out.= "</tr>\n";
349
+                        $out .= "</tr>\n";
350 350
                     }
351 351
                 }
352 352
             }
353 353
 
354
-            if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']) || $nblines)
354
+            if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines)
355 355
             {
356
-                $out.= "</table>\n";
356
+                $out .= "</table>\n";
357 357
             }
358 358
 
359 359
             // If invisible box with no contents
360
-            if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && ! $nblines) $out.= "<br>\n";
360
+            if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "<br>\n";
361 361
 
362
-            $out.= "</div>\n";
362
+            $out .= "</div>\n";
363 363
 
364
-            $out.= "<!-- Box ".get_class($this)." end -->\n\n";
365
-            if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
364
+            $out .= "<!-- Box ".get_class($this)." end -->\n\n";
365
+            if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
366 366
                 dol_filecache($cachedir, $filename, $out);
367 367
             }
368 368
         } else {
369 369
             dol_syslog(get_class($this).'::showBoxCached');
370 370
             $out = "<!-- Box ".get_class($this)." from cache -->";
371
-            $out.= dol_readcachefile($cachedir, $filename);
371
+            $out .= dol_readcachefile($cachedir, $filename);
372 372
         }
373 373
 
374 374
         if ($nooutput) return $out;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 *  @param	array	$forcedirwidget		null=All default directories. This parameter is used by modulebuilder module only.
386 386
 	 * 	@return	array						Array list of widget
387 387
 	 */
388
-	static function getWidgetsList($forcedirwidget=null)
388
+	static function getWidgetsList($forcedirwidget = null)
389 389
 	{
390 390
 		global $conf, $langs, $db;
391 391
 
@@ -397,44 +397,44 @@  discard block
 block discarded – undo
397 397
 		$orders = array();
398 398
 		$i = 0;
399 399
 
400
-		$dirwidget=array_merge(array('/core/boxes/'));
400
+		$dirwidget = array_merge(array('/core/boxes/'));
401 401
 		if (is_array($forcedirwidget))
402 402
 		{
403
-			$dirwidget=$forcedirwidget;
403
+			$dirwidget = $forcedirwidget;
404 404
 		}
405 405
 
406
-		foreach($dirwidget as $reldir)
406
+		foreach ($dirwidget as $reldir)
407 407
 		{
408
-			$dir=dol_buildpath($reldir,0);
409
-			$newdir=dol_osencode($dir);
408
+			$dir = dol_buildpath($reldir, 0);
409
+			$newdir = dol_osencode($dir);
410 410
 
411 411
 			// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
412
-			if (! is_dir($newdir)) continue;
412
+			if (!is_dir($newdir)) continue;
413 413
 
414
-			$handle=opendir($newdir);
414
+			$handle = opendir($newdir);
415 415
 			if (is_resource($handle))
416 416
 			{
417
-				while (($file = readdir($handle))!==false)
417
+				while (($file = readdir($handle)) !== false)
418 418
 				{
419
-					if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/',$file,$reg))
419
+					if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg))
420 420
 					{
421
-						if (preg_match('/\.back$/',$file)) continue;
421
+						if (preg_match('/\.back$/', $file)) continue;
422 422
 
423
-						$part1=$reg[1];
423
+						$part1 = $reg[1];
424 424
 
425 425
 						$modName = ucfirst($reg[1]);
426 426
 						//print "file=$file"; print "modName=$modName"; exit;
427
-						if (in_array($modName,$modules))
427
+						if (in_array($modName, $modules))
428 428
 						{
429 429
 							$langs->load("errors");
430
-							print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget",$modName,"").'</div>';
430
+							print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget", $modName, "").'</div>';
431 431
 						}
432 432
 						else
433 433
 						{
434 434
 							try {
435 435
 								include_once $newdir.'/'.$file;
436 436
 							}
437
-							catch(Exception $e)
437
+							catch (Exception $e)
438 438
 							{
439 439
 								print $e->getMessage();
440 440
 							}
@@ -442,10 +442,10 @@  discard block
 block discarded – undo
442 442
 
443 443
 						$files[$i] = $file;
444 444
 						$fullpath[$i] = $dir.'/'.$file;
445
-						$relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file;
446
-						$iscoreorexternal[$i] = ($reldir == '/core/boxes/'?'internal':'external');
445
+						$relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file;
446
+						$iscoreorexternal[$i] = ($reldir == '/core/boxes/' ? 'internal' : 'external');
447 447
 						$modules[$i] = $modName;
448
-						$orders[$i] = $part1;   // Set sort criteria value
448
+						$orders[$i] = $part1; // Set sort criteria value
449 449
 
450 450
 						$i++;
451 451
 					}
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 			$modName = $modules[$key];
466 466
 			if (empty($modName)) continue;
467 467
 
468
-			if (! class_exists($modName))
468
+			if (!class_exists($modName))
469 469
 			{
470 470
 				print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."<br>\n";
471 471
 				continue;
@@ -475,26 +475,26 @@  discard block
 block discarded – undo
475 475
 			if (is_object($objMod))
476 476
 			{
477 477
 				// Define disabledbyname and disabledbymodule
478
-				$disabledbyname=0;
479
-				$module='';
478
+				$disabledbyname = 0;
479
+				$module = '';
480 480
 
481 481
 				// Check if widget file is disabled by name
482
-				if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1;
482
+				if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1;
483 483
 
484 484
 				// We set info of modules
485
-				$widget[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic');
485
+				$widget[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto) : img_object('', 'generic');
486 486
 				$widget[$j]['file'] = $files[$key];
487 487
 				$widget[$j]['fullpath'] = $fullpath[$key];
488 488
 				$widget[$j]['relpath'] = $relpath[$key];
489 489
 				$widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
490 490
 				//$widget[$j]['version'] = $objMod->getVersion();
491
-				$widget[$j]['status'] = img_picto($langs->trans("Active"),'tick');
491
+				$widget[$j]['status'] = img_picto($langs->trans("Active"), 'tick');
492 492
 				if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = '';
493 493
 
494
-				$text ='<b>'.$langs->trans("Description").':</b><br>';
495
-				$text.=$objMod->boxlabel.'<br>';
496
-				$text.='<br><b>'.$langs->trans("Status").':</b><br>';
497
-				if ($disabledbymodule == 2) $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'<br>';
494
+				$text = '<b>'.$langs->trans("Description").':</b><br>';
495
+				$text .= $objMod->boxlabel.'<br>';
496
+				$text .= '<br><b>'.$langs->trans("Status").':</b><br>';
497
+				if ($disabledbymodule == 2) $text .= $langs->trans("HooksDisabledAsModuleDisabled", $module).'<br>';
498 498
 
499 499
 				$widget[$j]['info'] = $text;
500 500
 			}
Please login to merge, or discard this patch.
Braces   +88 added lines, -35 removed lines patch added patch discarded remove patch
@@ -161,13 +161,11 @@  discard block
 block discarded – undo
161 161
 				$this->box_order=$obj->box_order;
162 162
 				$this->fk_user=$obj->fk_user;
163 163
 				return 1;
164
-			}
165
-			else
164
+			} else
166 165
 			{
167 166
 				return -1;
168 167
 			}
169
-		}
170
-		else
168
+		} else
171 169
 		{
172 170
 			return -1;
173 171
 		}
@@ -208,7 +206,10 @@  discard block
 block discarded – undo
208 206
 	{
209 207
 		global $langs, $user, $conf;
210 208
 
211
-		if (! empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n';    // Nothing done if hidden (for example when user has no permission)
209
+		if (! empty($this->hidden)) {
210
+		    return '\n<!-- Box ".get_class($this)." hidden -->\n';
211
+		}
212
+		// Nothing done if hidden (for example when user has no permission)
212 213
 
213 214
         require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
214 215
 
@@ -226,7 +227,9 @@  discard block
 block discarded – undo
226 227
 
227 228
             // Define nbcol and nblines of the box to show
228 229
             $nbcol=0;
229
-            if (isset($contents[0])) $nbcol=count($contents[0]);
230
+            if (isset($contents[0])) {
231
+                $nbcol=count($contents[0]);
232
+            }
230 233
             $nblines=count($contents);
231 234
 
232 235
             $out.= "\n<!-- Box ".get_class($this)." start -->\n";
@@ -259,9 +262,15 @@  discard block
 block discarded – undo
259 262
                 if (! empty($conf->use_javascript_ajax))
260 263
                 {
261 264
                     $sublink='';
262
-                    if (! empty($head['sublink']))  $sublink.= '<a href="'.$head['sublink'].'"'.(empty($head['target'])?'':' target="'.$head['target'].'"').'>';
263
-                    if (! empty($head['subpicto'])) $sublink.= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium '.(empty($head['subclass'])?'':$head['subclass']).'" id="idsubimg'.$this->boxcode.'"');
264
-                    if (! empty($head['sublink']))  $sublink.= '</a>';
265
+                    if (! empty($head['sublink'])) {
266
+                        $sublink.= '<a href="'.$head['sublink'].'"'.(empty($head['target'])?'':' target="'.$head['target'].'"').'>';
267
+                    }
268
+                    if (! empty($head['subpicto'])) {
269
+                        $sublink.= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium '.(empty($head['subclass'])?'':$head['subclass']).'" id="idsubimg'.$this->boxcode.'"');
270
+                    }
271
+                    if (! empty($head['sublink'])) {
272
+                        $sublink.= '</a>';
273
+                    }
265 274
 
266 275
                     $out.= '<td class="nocellnopadd boxclose right nowraponall">';
267 276
                     $out.=$sublink;
@@ -270,7 +279,9 @@  discard block
 block discarded – undo
270 279
                     $out.= img_picto($langs->trans("CloseBox",$this->box_id),'close_title','class="opacitymedium boxclose cursorpointer" rel="x:y" id="imgclose'.$this->box_id.'"');
271 280
                     $label=$head['text'];
272 281
                     //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')';
273
-                    if (! empty($head['graph'])) $label.=' <span class="opacitymedium fa fa-bar-chart"></span>';
282
+                    if (! empty($head['graph'])) {
283
+                        $label.=' <span class="opacitymedium fa fa-bar-chart"></span>';
284
+                    }
274 285
                     $out.= '<input type="hidden" id="boxlabelentry'.$this->box_id.'" value="'.dol_escape_htmltag($label).'">';
275 286
                     $out.= '</td></tr></table>';
276 287
                 }
@@ -287,15 +298,20 @@  discard block
 block discarded – undo
287 298
                     if (isset($contents[$i]))
288 299
                     {
289 300
                         // TR
290
-                        if (isset($contents[$i][0]['tr'])) $out.= '<tr '.$contents[$i][0]['tr'].'>';
291
-                        else $out.= '<tr class="oddeven">';
301
+                        if (isset($contents[$i][0]['tr'])) {
302
+                            $out.= '<tr '.$contents[$i][0]['tr'].'>';
303
+                        } else {
304
+                            $out.= '<tr class="oddeven">';
305
+                        }
292 306
 
293 307
                         // Loop on each TD
294 308
                         $nbcolthisline=count($contents[$i]);
295 309
                         for ($j=0; $j < $nbcolthisline; $j++) {
296 310
                             // Define tdparam
297 311
                             $tdparam='';
298
-                            if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td'];
312
+                            if (isset($contents[$i][$j]['td'])) {
313
+                                $tdparam.=' '.$contents[$i][$j]['td'];
314
+                            }
299 315
 
300 316
                             $text=isset($contents[$i][$j]['text'])?$contents[$i][$j]['text']:'';
301 317
                             $textwithnotags=preg_replace('/<([^>]+)>/i','',$text);
@@ -303,7 +319,9 @@  discard block
 block discarded – undo
303 319
                             $text2withnotags=preg_replace('/<([^>]+)>/i','',$text2);
304 320
                             $textnoformat=isset($contents[$i][$j]['textnoformat'])?$contents[$i][$j]['textnoformat']:'';
305 321
                             //$out.= "xxx $textwithnotags y";
306
-                            if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip']="";
322
+                            if (empty($contents[$i][$j]['tooltip'])) {
323
+                                $contents[$i][$j]['tooltip']="";
324
+                            }
307 325
                             $tooltip=isset($contents[$i][$j]['tooltip'])?$contents[$i][$j]['tooltip']:'';
308 326
 
309 327
                             $out.= '<td'.$tdparam.'>'."\n";
@@ -329,19 +347,39 @@  discard block
 block discarded – undo
329 347
                             }
330 348
 
331 349
                             $maxlength=$MAXLENGTHBOX;
332
-                            if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
350
+                            if (! empty($contents[$i][$j]['maxlength'])) {
351
+                                $maxlength=$contents[$i][$j]['maxlength'];
352
+                            }
333 353
 
334
-                            if ($maxlength) $textwithnotags=dol_trunc($textwithnotags,$maxlength);
335
-                            if (preg_match('/^<img/i',$text) || preg_match('/^<div/i',$text) || ! empty($contents[$i][$j]['asis'])) $out.= $text;   // show text with no html cleaning
336
-                            else $out.= $textwithnotags;                // show text with html cleaning
354
+                            if ($maxlength) {
355
+                                $textwithnotags=dol_trunc($textwithnotags,$maxlength);
356
+                            }
357
+                            if (preg_match('/^<img/i',$text) || preg_match('/^<div/i',$text) || ! empty($contents[$i][$j]['asis'])) {
358
+                                $out.= $text;
359
+                            }
360
+                            // show text with no html cleaning
361
+                            else {
362
+                                $out.= $textwithnotags;
363
+                            }
364
+                            // show text with html cleaning
337 365
 
338 366
                             // End Url
339
-                            if (! empty($contents[$i][$j]['url'])) $out.= '</a>';
367
+                            if (! empty($contents[$i][$j]['url'])) {
368
+                                $out.= '</a>';
369
+                            }
340 370
 
341
-                            if (preg_match('/^<img/i',$text2) || preg_match('/^<div/i',$text2) || ! empty($contents[$i][$j]['asis2'])) $out.= $text2; // show text with no html cleaning
342
-                            else $out.= $text2withnotags;               // show text with html cleaning
371
+                            if (preg_match('/^<img/i',$text2) || preg_match('/^<div/i',$text2) || ! empty($contents[$i][$j]['asis2'])) {
372
+                                $out.= $text2;
373
+                            }
374
+                            // show text with no html cleaning
375
+                            else {
376
+                                $out.= $text2withnotags;
377
+                            }
378
+                            // show text with html cleaning
343 379
 
344
-                            if (! empty($textnoformat)) $out.= "\n".$textnoformat."\n";
380
+                            if (! empty($textnoformat)) {
381
+                                $out.= "\n".$textnoformat."\n";
382
+                            }
345 383
 
346 384
                             $out.= "</td>\n";
347 385
                         }
@@ -357,7 +395,9 @@  discard block
 block discarded – undo
357 395
             }
358 396
 
359 397
             // If invisible box with no contents
360
-            if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && ! $nblines) $out.= "<br>\n";
398
+            if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && ! $nblines) {
399
+                $out.= "<br>\n";
400
+            }
361 401
 
362 402
             $out.= "</div>\n";
363 403
 
@@ -371,8 +411,11 @@  discard block
 block discarded – undo
371 411
             $out.= dol_readcachefile($cachedir, $filename);
372 412
         }
373 413
 
374
-        if ($nooutput) return $out;
375
-        else print $out;
414
+        if ($nooutput) {
415
+            return $out;
416
+        } else {
417
+            print $out;
418
+        }
376 419
 
377 420
         return '';
378 421
 	}
@@ -409,7 +452,9 @@  discard block
 block discarded – undo
409 452
 			$newdir=dol_osencode($dir);
410 453
 
411 454
 			// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
412
-			if (! is_dir($newdir)) continue;
455
+			if (! is_dir($newdir)) {
456
+			    continue;
457
+			}
413 458
 
414 459
 			$handle=opendir($newdir);
415 460
 			if (is_resource($handle))
@@ -418,7 +463,9 @@  discard block
 block discarded – undo
418 463
 				{
419 464
 					if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/',$file,$reg))
420 465
 					{
421
-						if (preg_match('/\.back$/',$file)) continue;
466
+						if (preg_match('/\.back$/',$file)) {
467
+						    continue;
468
+						}
422 469
 
423 470
 						$part1=$reg[1];
424 471
 
@@ -428,13 +475,11 @@  discard block
 block discarded – undo
428 475
 						{
429 476
 							$langs->load("errors");
430 477
 							print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget",$modName,"").'</div>';
431
-						}
432
-						else
478
+						} else
433 479
 						{
434 480
 							try {
435 481
 								include_once $newdir.'/'.$file;
436
-							}
437
-							catch(Exception $e)
482
+							} catch(Exception $e)
438 483
 							{
439 484
 								print $e->getMessage();
440 485
 							}
@@ -463,7 +508,9 @@  discard block
 block discarded – undo
463 508
 		foreach ($orders as $key => $value)
464 509
 		{
465 510
 			$modName = $modules[$key];
466
-			if (empty($modName)) continue;
511
+			if (empty($modName)) {
512
+			    continue;
513
+			}
467 514
 
468 515
 			if (! class_exists($modName))
469 516
 			{
@@ -479,7 +526,9 @@  discard block
 block discarded – undo
479 526
 				$module='';
480 527
 
481 528
 				// Check if widget file is disabled by name
482
-				if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1;
529
+				if (preg_match('/NORUN$/i',$files[$key])) {
530
+				    $disabledbyname=1;
531
+				}
483 532
 
484 533
 				// We set info of modules
485 534
 				$widget[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic');
@@ -489,12 +538,16 @@  discard block
 block discarded – undo
489 538
 				$widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
490 539
 				//$widget[$j]['version'] = $objMod->getVersion();
491 540
 				$widget[$j]['status'] = img_picto($langs->trans("Active"),'tick');
492
-				if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = '';
541
+				if ($disabledbyname > 0 || $disabledbymodule > 1) {
542
+				    $widget[$j]['status'] = '';
543
+				}
493 544
 
494 545
 				$text ='<b>'.$langs->trans("Description").':</b><br>';
495 546
 				$text.=$objMod->boxlabel.'<br>';
496 547
 				$text.='<br><b>'.$langs->trans("Status").':</b><br>';
497
-				if ($disabledbymodule == 2) $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'<br>';
548
+				if ($disabledbymodule == 2) {
549
+				    $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'<br>';
550
+				}
498 551
 
499 552
 				$widget[$j]['info'] = $text;
500 553
 			}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_ficheinter.php 3 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -31,144 +31,144 @@
 block discarded – undo
31 31
  */
32 32
 class box_ficheinter extends ModeleBoxes
33 33
 {
34
-	var $boxcode="ficheinter";
35
-	var $boximg="object_intervention";
36
-	var $boxlabel="BoxFicheInter";
37
-	var $depends = array("ficheinter");	// conf->contrat->enabled
34
+    var $boxcode="ficheinter";
35
+    var $boximg="object_intervention";
36
+    var $boxlabel="BoxFicheInter";
37
+    var $depends = array("ficheinter");	// conf->contrat->enabled
38 38
 
39
-	/**
39
+    /**
40 40
      * @var DoliDB Database handler.
41 41
      */
42 42
     public $db;
43 43
     
44
-	var $param;
45
-
46
-	var $info_box_head = array();
47
-	var $info_box_contents = array();
48
-
49
-
50
-	/**
51
-	 *  Constructor
52
-	 *
53
-	 *  @param  DoliDB  $db         Database handler
54
-	 *  @param  string  $param      More parameters
55
-	 */
56
-	function __construct($db,$param)
57
-	{
58
-	    global $user;
59
-
60
-	    $this->db=$db;
61
-
62
-	    $this->hidden=! ($user->rights->ficheinter->lire);
63
-	}
64
-
65
-	/**
66
-	 *  Load data for box to show them later
67
-	 *
68
-	 *  @param	int		$max        Maximum number of records to load
69
-	 *  @return	void
70
-	*/
71
-	function loadBox($max=10)
72
-	{
73
-		global $user, $langs, $db, $conf;
74
-
75
-		$this->max=$max;
76
-
77
-		include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
78
-		$ficheinterstatic=new Fichinter($db);
79
-
80
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter",$max));
81
-
82
-		if (! empty($user->rights->ficheinter->lire))
83
-		{
84
-			$sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,";
85
-			$sql.= " f.datec,";
86
-			$sql.= " f.date_valid as datev,";
87
-			$sql.= " f.tms as datem,";
88
-			$sql.= " s.nom as name, s.rowid as socid, s.client";
89
-			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
90
-			if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
91
-			$sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
92
-			$sql.= " WHERE f.fk_soc = s.rowid ";
93
-			$sql.= " AND f.entity = ".$conf->entity;
94
-			if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
-			if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
96
-			$sql.= " ORDER BY f.tms DESC";
97
-			$sql.= $db->plimit($max, 0);
98
-
99
-			dol_syslog(get_class($this).'::loadBox', LOG_DEBUG);
100
-			$resql = $db->query($sql);
101
-			if ($resql)
102
-			{
103
-				$num = $db->num_rows($resql);
104
-				$now=dol_now();
105
-
106
-				$i = 0;
107
-
108
-				while ($i < $num)
109
-				{
110
-					$objp = $db->fetch_object($resql);
111
-					$datec=$db->jdate($objp->datec);
112
-
113
-					$ficheinterstatic->statut=$objp->fk_statut;
114
-					$ficheinterstatic->id=$objp->rowid;
115
-					$ficheinterstatic->ref=$objp->ref;
116
-
117
-					$this->info_box_contents[$i][] = array('td' => '',
118
-					'text' => $ficheinterstatic->getNomUrl(1),
119
-					'asis' => 1
120
-					);
121
-
122
-					$this->info_box_contents[$i][] = array('td' => 'align="left" width="16"',
123
-					'logo' => 'company',
124
-					'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
125
-
126
-					$this->info_box_contents[$i][] = array('td' => '',
127
-					'text' => dol_trunc($objp->name,40),
128
-					'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
129
-
130
-					$this->info_box_contents[$i][] = array('td' => 'class="right"',
131
-					'text' => dol_print_date($datec,'day'));
132
-
133
-					$this->info_box_contents[$i][] = array('td' => 'align="right" class="nowrap"',
134
-					'text' => $ficheinterstatic->getLibStatut(6),
135
-					'asis'=>1
136
-					);
137
-
138
-					$i++;
139
-				}
140
-
141
-				if ($num==0) $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions"));
142
-
143
-				$db->free($resql);
144
-			}
145
-			else
146
-			{
147
-				$this->info_box_contents[0][] = array(  'td' => '',
148
-				'maxlength'=>500,
149
-				'text' => ($db->error().' sql='.$sql));
150
-			}
151
-		}
152
-		else
153
-		{
154
-			$this->info_box_contents[0][] = array(
155
-			    'td' => 'align="left" class="nohover opacitymedium"',
156
-			    'text' => $langs->trans("ReadPermissionNotAllowed")
157
-			);
158
-		}
159
-	}
160
-
161
-	/**
162
-	 *	Method to show box
163
-	 *
164
-	 *	@param	array	$head       Array with properties of box title
165
-	 *	@param  array	$contents   Array with properties of box lines
166
-	 *  @param	int		$nooutput	No print, only return string
167
-	 *	@return	string
168
-	 */
44
+    var $param;
45
+
46
+    var $info_box_head = array();
47
+    var $info_box_contents = array();
48
+
49
+
50
+    /**
51
+     *  Constructor
52
+     *
53
+     *  @param  DoliDB  $db         Database handler
54
+     *  @param  string  $param      More parameters
55
+     */
56
+    function __construct($db,$param)
57
+    {
58
+        global $user;
59
+
60
+        $this->db=$db;
61
+
62
+        $this->hidden=! ($user->rights->ficheinter->lire);
63
+    }
64
+
65
+    /**
66
+     *  Load data for box to show them later
67
+     *
68
+     *  @param	int		$max        Maximum number of records to load
69
+     *  @return	void
70
+     */
71
+    function loadBox($max=10)
72
+    {
73
+        global $user, $langs, $db, $conf;
74
+
75
+        $this->max=$max;
76
+
77
+        include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
78
+        $ficheinterstatic=new Fichinter($db);
79
+
80
+        $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter",$max));
81
+
82
+        if (! empty($user->rights->ficheinter->lire))
83
+        {
84
+            $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,";
85
+            $sql.= " f.datec,";
86
+            $sql.= " f.date_valid as datev,";
87
+            $sql.= " f.tms as datem,";
88
+            $sql.= " s.nom as name, s.rowid as socid, s.client";
89
+            $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
90
+            if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
91
+            $sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
92
+            $sql.= " WHERE f.fk_soc = s.rowid ";
93
+            $sql.= " AND f.entity = ".$conf->entity;
94
+            if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
+            if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
96
+            $sql.= " ORDER BY f.tms DESC";
97
+            $sql.= $db->plimit($max, 0);
98
+
99
+            dol_syslog(get_class($this).'::loadBox', LOG_DEBUG);
100
+            $resql = $db->query($sql);
101
+            if ($resql)
102
+            {
103
+                $num = $db->num_rows($resql);
104
+                $now=dol_now();
105
+
106
+                $i = 0;
107
+
108
+                while ($i < $num)
109
+                {
110
+                    $objp = $db->fetch_object($resql);
111
+                    $datec=$db->jdate($objp->datec);
112
+
113
+                    $ficheinterstatic->statut=$objp->fk_statut;
114
+                    $ficheinterstatic->id=$objp->rowid;
115
+                    $ficheinterstatic->ref=$objp->ref;
116
+
117
+                    $this->info_box_contents[$i][] = array('td' => '',
118
+                    'text' => $ficheinterstatic->getNomUrl(1),
119
+                    'asis' => 1
120
+                    );
121
+
122
+                    $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"',
123
+                    'logo' => 'company',
124
+                    'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
125
+
126
+                    $this->info_box_contents[$i][] = array('td' => '',
127
+                    'text' => dol_trunc($objp->name,40),
128
+                    'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
129
+
130
+                    $this->info_box_contents[$i][] = array('td' => 'class="right"',
131
+                    'text' => dol_print_date($datec,'day'));
132
+
133
+                    $this->info_box_contents[$i][] = array('td' => 'align="right" class="nowrap"',
134
+                    'text' => $ficheinterstatic->getLibStatut(6),
135
+                    'asis'=>1
136
+                    );
137
+
138
+                    $i++;
139
+                }
140
+
141
+                if ($num==0) $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions"));
142
+
143
+                $db->free($resql);
144
+            }
145
+            else
146
+            {
147
+                $this->info_box_contents[0][] = array(  'td' => '',
148
+                'maxlength'=>500,
149
+                'text' => ($db->error().' sql='.$sql));
150
+            }
151
+        }
152
+        else
153
+        {
154
+            $this->info_box_contents[0][] = array(
155
+                'td' => 'align="left" class="nohover opacitymedium"',
156
+                'text' => $langs->trans("ReadPermissionNotAllowed")
157
+            );
158
+        }
159
+    }
160
+
161
+    /**
162
+     *	Method to show box
163
+     *
164
+     *	@param	array	$head       Array with properties of box title
165
+     *	@param  array	$contents   Array with properties of box lines
166
+     *  @param	int		$nooutput	No print, only return string
167
+     *	@return	string
168
+     */
169 169
     function showBox($head = null, $contents = null, $nooutput=0)
170 170
     {
171
-		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
172
-	}
171
+        return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
172
+    }
173 173
 }
174 174
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class box_ficheinter extends ModeleBoxes
33 33
 {
34
-	var $boxcode="ficheinter";
35
-	var $boximg="object_intervention";
36
-	var $boxlabel="BoxFicheInter";
37
-	var $depends = array("ficheinter");	// conf->contrat->enabled
34
+	var $boxcode = "ficheinter";
35
+	var $boximg = "object_intervention";
36
+	var $boxlabel = "BoxFicheInter";
37
+	var $depends = array("ficheinter"); // conf->contrat->enabled
38 38
 
39 39
 	/**
40 40
      * @var DoliDB Database handler.
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 	 *  @param  DoliDB  $db         Database handler
54 54
 	 *  @param  string  $param      More parameters
55 55
 	 */
56
-	function __construct($db,$param)
56
+	function __construct($db, $param)
57 57
 	{
58 58
 	    global $user;
59 59
 
60
-	    $this->db=$db;
60
+	    $this->db = $db;
61 61
 
62
-	    $this->hidden=! ($user->rights->ficheinter->lire);
62
+	    $this->hidden = !($user->rights->ficheinter->lire);
63 63
 	}
64 64
 
65 65
 	/**
@@ -68,51 +68,51 @@  discard block
 block discarded – undo
68 68
 	 *  @param	int		$max        Maximum number of records to load
69 69
 	 *  @return	void
70 70
 	*/
71
-	function loadBox($max=10)
71
+	function loadBox($max = 10)
72 72
 	{
73 73
 		global $user, $langs, $db, $conf;
74 74
 
75
-		$this->max=$max;
75
+		$this->max = $max;
76 76
 
77 77
 		include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
78
-		$ficheinterstatic=new Fichinter($db);
78
+		$ficheinterstatic = new Fichinter($db);
79 79
 
80
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter",$max));
80
+		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max));
81 81
 
82
-		if (! empty($user->rights->ficheinter->lire))
82
+		if (!empty($user->rights->ficheinter->lire))
83 83
 		{
84 84
 			$sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,";
85
-			$sql.= " f.datec,";
86
-			$sql.= " f.date_valid as datev,";
87
-			$sql.= " f.tms as datem,";
88
-			$sql.= " s.nom as name, s.rowid as socid, s.client";
89
-			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
90
-			if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
91
-			$sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
92
-			$sql.= " WHERE f.fk_soc = s.rowid ";
93
-			$sql.= " AND f.entity = ".$conf->entity;
94
-			if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
-			if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
96
-			$sql.= " ORDER BY f.tms DESC";
97
-			$sql.= $db->plimit($max, 0);
85
+			$sql .= " f.datec,";
86
+			$sql .= " f.date_valid as datev,";
87
+			$sql .= " f.tms as datem,";
88
+			$sql .= " s.nom as name, s.rowid as socid, s.client";
89
+			$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
90
+			if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
91
+			$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
92
+			$sql .= " WHERE f.fk_soc = s.rowid ";
93
+			$sql .= " AND f.entity = ".$conf->entity;
94
+			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
95
+			if ($user->societe_id)	$sql .= " AND s.rowid = ".$user->societe_id;
96
+			$sql .= " ORDER BY f.tms DESC";
97
+			$sql .= $db->plimit($max, 0);
98 98
 
99 99
 			dol_syslog(get_class($this).'::loadBox', LOG_DEBUG);
100 100
 			$resql = $db->query($sql);
101 101
 			if ($resql)
102 102
 			{
103 103
 				$num = $db->num_rows($resql);
104
-				$now=dol_now();
104
+				$now = dol_now();
105 105
 
106 106
 				$i = 0;
107 107
 
108 108
 				while ($i < $num)
109 109
 				{
110 110
 					$objp = $db->fetch_object($resql);
111
-					$datec=$db->jdate($objp->datec);
111
+					$datec = $db->jdate($objp->datec);
112 112
 
113
-					$ficheinterstatic->statut=$objp->fk_statut;
114
-					$ficheinterstatic->id=$objp->rowid;
115
-					$ficheinterstatic->ref=$objp->ref;
113
+					$ficheinterstatic->statut = $objp->fk_statut;
114
+					$ficheinterstatic->id = $objp->rowid;
115
+					$ficheinterstatic->ref = $objp->ref;
116 116
 
117 117
 					$this->info_box_contents[$i][] = array('td' => '',
118 118
 					'text' => $ficheinterstatic->getNomUrl(1),
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 					'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
125 125
 
126 126
 					$this->info_box_contents[$i][] = array('td' => '',
127
-					'text' => dol_trunc($objp->name,40),
127
+					'text' => dol_trunc($objp->name, 40),
128 128
 					'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
129 129
 
130 130
 					$this->info_box_contents[$i][] = array('td' => 'class="right"',
131
-					'text' => dol_print_date($datec,'day'));
131
+					'text' => dol_print_date($datec, 'day'));
132 132
 
133 133
 					$this->info_box_contents[$i][] = array('td' => 'align="right" class="nowrap"',
134 134
 					'text' => $ficheinterstatic->getLibStatut(6),
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 					$i++;
139 139
 				}
140 140
 
141
-				if ($num==0) $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions"));
141
+				if ($num == 0) $this->info_box_contents[$i][] = array('td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInterventions"));
142 142
 
143 143
 				$db->free($resql);
144 144
 			}
145 145
 			else
146 146
 			{
147
-				$this->info_box_contents[0][] = array(  'td' => '',
147
+				$this->info_box_contents[0][] = array('td' => '',
148 148
 				'maxlength'=>500,
149 149
 				'text' => ($db->error().' sql='.$sql));
150 150
 			}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 *  @param	int		$nooutput	No print, only return string
167 167
 	 *	@return	string
168 168
 	 */
169
-    function showBox($head = null, $contents = null, $nooutput=0)
169
+    function showBox($head = null, $contents = null, $nooutput = 0)
170 170
     {
171 171
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
172 172
 	}
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,12 +87,18 @@  discard block
 block discarded – undo
87 87
 			$sql.= " f.tms as datem,";
88 88
 			$sql.= " s.nom as name, s.rowid as socid, s.client";
89 89
 			$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
90
-			if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
90
+			if (! $user->rights->societe->client->voir) {
91
+			    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
92
+			}
91 93
 			$sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
92 94
 			$sql.= " WHERE f.fk_soc = s.rowid ";
93 95
 			$sql.= " AND f.entity = ".$conf->entity;
94
-			if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
-			if($user->societe_id)	$sql.= " AND s.rowid = ".$user->societe_id;
96
+			if (! $user->rights->societe->client->voir && !$user->societe_id) {
97
+			    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
98
+			}
99
+			if($user->societe_id) {
100
+			    $sql.= " AND s.rowid = ".$user->societe_id;
101
+			}
96 102
 			$sql.= " ORDER BY f.tms DESC";
97 103
 			$sql.= $db->plimit($max, 0);
98 104
 
@@ -138,18 +144,18 @@  discard block
 block discarded – undo
138 144
 					$i++;
139 145
 				}
140 146
 
141
-				if ($num==0) $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions"));
147
+				if ($num==0) {
148
+				    $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions"));
149
+				}
142 150
 
143 151
 				$db->free($resql);
144
-			}
145
-			else
152
+			} else
146 153
 			{
147 154
 				$this->info_box_contents[0][] = array(  'td' => '',
148 155
 				'maxlength'=>500,
149 156
 				'text' => ($db->error().' sql='.$sql));
150 157
 			}
151
-		}
152
-		else
158
+		} else
153 159
 		{
154 160
 			$this->info_box_contents[0][] = array(
155 161
 			    'td' => 'align="left" class="nohover opacitymedium"',
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_activity.php 3 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -102,89 +102,89 @@  discard block
 block discarded – undo
102 102
         // list the summary of the propals
103 103
         if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
104 104
         {
105
-        	include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
106
-        	$propalstatic=new Propal($db);
107
-
108
-        	$cachedir = DOL_DATA_ROOT.'/propale/temp';
109
-        	$filename = '/boxactivity-propal'.$fileid;
110
-        	$refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
111
-        	$data = array();
112
-        	if ($refresh)
113
-        	{
114
-        		$sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
115
-        		$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
116
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
117
-        		$sql.= ")";
118
-        		$sql.= " WHERE p.entity IN (".getEntity('propal').")";
119
-        		$sql.= " AND p.fk_soc = s.rowid";
120
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
121
-        		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
122
-        		$sql.= " AND p.datep >= '".$db->idate($tmpdate)."'";
123
-        		$sql.= " AND p.date_cloture IS NULL"; // just unclosed
124
-        		$sql.= " GROUP BY p.fk_statut";
125
-        		$sql.= " ORDER BY p.fk_statut DESC";
126
-
127
-        		$result = $db->query($sql);
128
-        		if ($result)
129
-        		{
130
-        			$num = $db->num_rows($result);
131
-
132
-        			$j=0;
133
-        			while ($j < $num) {
134
-        				$data[$j]=$db->fetch_object($result);
135
-        				$j++;
136
-        			}
137
-        			if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
138
-        				dol_filecache($cachedir, $filename, $data);
139
-        			}
140
-        			$db->free($result);
141
-        		} else {
142
-        			dol_print_error($db);
143
-        		}
144
-        	}
145
-        	else
146
-        	{
147
-        		$data = dol_readcachefile($cachedir, $filename);
148
-        	}
149
-
150
-        	if (! empty($data))
151
-        	{
152
-        		$j=0;
153
-        		while ($j < count($data))
154
-        		{
155
-        			$this->info_box_contents[$line][0] = array(
156
-        			'td' => 'align="left" width="16"',
157
-        			'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
158
-        			'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
159
-        			'logo' => 'object_propal'
160
-        			);
161
-
162
-        			$this->info_box_contents[$line][1] = array(
163
-        			'td' => '',
164
-        			'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
165
-        			);
166
-
167
-        			$this->info_box_contents[$line][2] = array(
168
-        			'td' => 'class="right"',
169
-        			'text' => $data[$j]->nb,
170
-        			'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
171
-        			'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
172
-        			);
173
-        			$totalnb += $data[$j]->nb;
174
-
175
-        			$this->info_box_contents[$line][3] = array(
176
-        			'td' => 'class="right"',
177
-        			'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
178
-        			);
179
-        			$this->info_box_contents[$line][4] = array(
180
-        			'td' => 'align="right" width="18"',
181
-        			'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3),
182
-        			);
183
-
184
-        			$line++;
185
-        			$j++;
186
-        		}
187
-        	}
105
+            include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
106
+            $propalstatic=new Propal($db);
107
+
108
+            $cachedir = DOL_DATA_ROOT.'/propale/temp';
109
+            $filename = '/boxactivity-propal'.$fileid;
110
+            $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
111
+            $data = array();
112
+            if ($refresh)
113
+            {
114
+                $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
115
+                $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
116
+                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
117
+                $sql.= ")";
118
+                $sql.= " WHERE p.entity IN (".getEntity('propal').")";
119
+                $sql.= " AND p.fk_soc = s.rowid";
120
+                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
121
+                if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
122
+                $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'";
123
+                $sql.= " AND p.date_cloture IS NULL"; // just unclosed
124
+                $sql.= " GROUP BY p.fk_statut";
125
+                $sql.= " ORDER BY p.fk_statut DESC";
126
+
127
+                $result = $db->query($sql);
128
+                if ($result)
129
+                {
130
+                    $num = $db->num_rows($result);
131
+
132
+                    $j=0;
133
+                    while ($j < $num) {
134
+                        $data[$j]=$db->fetch_object($result);
135
+                        $j++;
136
+                    }
137
+                    if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
138
+                        dol_filecache($cachedir, $filename, $data);
139
+                    }
140
+                    $db->free($result);
141
+                } else {
142
+                    dol_print_error($db);
143
+                }
144
+            }
145
+            else
146
+            {
147
+                $data = dol_readcachefile($cachedir, $filename);
148
+            }
149
+
150
+            if (! empty($data))
151
+            {
152
+                $j=0;
153
+                while ($j < count($data))
154
+                {
155
+                    $this->info_box_contents[$line][0] = array(
156
+                    'td' => 'align="left" width="16"',
157
+                    'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
158
+                    'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
159
+                    'logo' => 'object_propal'
160
+                    );
161
+
162
+                    $this->info_box_contents[$line][1] = array(
163
+                    'td' => '',
164
+                    'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
165
+                    );
166
+
167
+                    $this->info_box_contents[$line][2] = array(
168
+                    'td' => 'class="right"',
169
+                    'text' => $data[$j]->nb,
170
+                    'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
171
+                    'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
172
+                    );
173
+                    $totalnb += $data[$j]->nb;
174
+
175
+                    $this->info_box_contents[$line][3] = array(
176
+                    'td' => 'class="right"',
177
+                    'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
178
+                    );
179
+                    $this->info_box_contents[$line][4] = array(
180
+                    'td' => 'align="right" width="18"',
181
+                    'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3),
182
+                    );
183
+
184
+                    $line++;
185
+                    $j++;
186
+                }
187
+            }
188 188
         }
189 189
 
190 190
         // list the summary of the orders
@@ -274,191 +274,191 @@  discard block
 block discarded – undo
274 274
         // list the summary of the bills
275 275
         if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
276 276
         {
277
-        	include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
278
-        	$facturestatic=new Facture($db);
279
-
280
-        	// part 1
281
-        	$cachedir = DOL_DATA_ROOT.'/facture/temp';
282
-        	$filename = '/boxactivity-invoice'.$fileid;
283
-
284
-        	$refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
285
-        	$data = array();
286
-        	if ($refresh)
287
-        	{
288
-        		$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
289
-        		$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
290
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
291
-        		$sql.= ")";
292
-        		$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
293
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
294
-        		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
295
-        		$sql.= " AND f.fk_soc = s.rowid";
296
-        		$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1";
297
-        		$sql.= " GROUP BY f.fk_statut";
298
-        		$sql.= " ORDER BY f.fk_statut DESC";
299
-
300
-        		$result = $db->query($sql);
301
-        		if ($result) {
302
-        			$num = $db->num_rows($result);
303
-        			$j=0;
304
-        			while ($j < $num) {
305
-        				$data[$j]=$db->fetch_object($result);
306
-        				$j++;
307
-        			}
308
-        			if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
309
-        				dol_filecache($cachedir, $filename, $data);
310
-        			}
311
-        			$db->free($result);
312
-        		} else {
313
-        			dol_print_error($db);
314
-        		}
315
-        	} else {
316
-        		$data = dol_readcachefile($cachedir, $filename);
317
-        	}
318
-
319
-        	if (! empty($data)) {
320
-        		$j=0;
321
-        		while ($j < count($data)) {
322
-        			$billurl="search_status=2&amp;paye=1&amp;year=".$data[$j]->annee;
323
-        			$this->info_box_contents[$line][0] = array(
324
-        			'td' => 'align="left" width="16"',
325
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
326
-        			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
327
-        			'logo' => 'bill',
328
-        			);
329
-
330
-        			$this->info_box_contents[$line][1] = array(
331
-        			'td' => '',
332
-        			'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee,
333
-        			);
334
-
335
-        			$this->info_box_contents[$line][2] = array(
336
-        			'td' => 'class="right"',
337
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
338
-        			'text' => $data[$j]->nb,
339
-        			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
340
-        			);
341
-
342
-        			$this->info_box_contents[$line][3] = array(
343
-        			'td' => 'class="right"',
344
-        			'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency)
345
-        			);
346
-
347
-        			// We add only for the current year
348
-       				$totalnb += $data[$j]->nb;
349
-
350
-        			$this->info_box_contents[$line][4] = array(
351
-        			'td' => 'align="right" width="18"',
352
-        			'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3),
353
-        			);
354
-        			$line++;
355
-        			$j++;
356
-        		}
357
-        		if (count($data)==0)
358
-        			$this->info_box_contents[$line][0] = array(
359
-        			'td' => 'align="center"',
360
-        			'text'=>$langs->trans("NoRecordedInvoices"),
361
-        			);
362
-        	}
363
-
364
-        	// part 2
365
-        	$cachedir = DOL_DATA_ROOT.'/facture/temp';
366
-        	$filename = '/boxactivity-invoice2'.$fileid;
367
-
368
-        	$refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
369
-
370
-        	$data = array();
371
-        	if ($refresh) {
372
-        		$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
373
-        		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
374
-        		$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
375
-        		$sql.= " AND f.fk_soc = s.rowid";
376
-        		$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0";
377
-        		$sql.= " GROUP BY f.fk_statut";
378
-        		$sql.= " ORDER BY f.fk_statut DESC";
379
-
380
-        		$result = $db->query($sql);
381
-        		if ($result) {
382
-        			$num = $db->num_rows($result);
383
-        			$j=0;
384
-        			while ($j < $num) {
385
-        				$data[$j]=$db->fetch_object($result);
386
-        				$j++;
387
-        			}
388
-        			if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
389
-        				dol_filecache($cachedir, $filename, $data);
390
-        			}
391
-        			$db->free($result);
392
-        		} else {
393
-        			dol_print_error($db);
394
-        		}
395
-        	} else {
396
-        		$data = dol_readcachefile($cachedir, $filename);
397
-        	}
398
-
399
-        	if (! empty($data)) {
400
-        		$alreadypaid=-1;
401
-
402
-        		$j=0;
403
-        		while ($j < count($data)) {
404
-        			$billurl="search_status=".$data[$j]->fk_statut."&amp;paye=0";
405
-        			$this->info_box_contents[$line][0] = array(
406
-        			'td' => 'align="left" width="16"',
407
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
408
-        			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
409
-        			'logo' => 'bill',
410
-        			);
411
-
412
-        			$this->info_box_contents[$line][1] = array(
413
-        			'td' => '',
414
-        			'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
415
-        			);
416
-
417
-        			$this->info_box_contents[$line][2] = array(
418
-        			'td' => 'class="right"',
419
-        			'text' => $data[$j]->nb,
420
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
421
-        			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
422
-        			);
423
-        			$totalnb += $data[$j]->nb;
424
-        			$this->info_box_contents[$line][3] = array(
425
-        			'td' => 'class="right"',
426
-        			'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
427
-        			);
428
-        			$this->info_box_contents[$line][4] = array(
429
-        			'td' => 'align="right" width="18"',
430
-        			'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid),
431
-        			);
432
-        			$line++;
433
-        			$j++;
434
-        		}
435
-        		if ($num==0)
436
-        			$this->info_box_contents[$line][0] = array(
437
-        			'td' => 'align="center"',
438
-        			'text'=>$langs->trans("NoRecordedInvoices"),
439
-        			);
440
-        	}
277
+            include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
278
+            $facturestatic=new Facture($db);
279
+
280
+            // part 1
281
+            $cachedir = DOL_DATA_ROOT.'/facture/temp';
282
+            $filename = '/boxactivity-invoice'.$fileid;
283
+
284
+            $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
285
+            $data = array();
286
+            if ($refresh)
287
+            {
288
+                $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
289
+                $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
290
+                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
291
+                $sql.= ")";
292
+                $sql.= " WHERE f.entity IN (".getEntity('invoice').')';
293
+                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
294
+                if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
295
+                $sql.= " AND f.fk_soc = s.rowid";
296
+                $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1";
297
+                $sql.= " GROUP BY f.fk_statut";
298
+                $sql.= " ORDER BY f.fk_statut DESC";
299
+
300
+                $result = $db->query($sql);
301
+                if ($result) {
302
+                    $num = $db->num_rows($result);
303
+                    $j=0;
304
+                    while ($j < $num) {
305
+                        $data[$j]=$db->fetch_object($result);
306
+                        $j++;
307
+                    }
308
+                    if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
309
+                        dol_filecache($cachedir, $filename, $data);
310
+                    }
311
+                    $db->free($result);
312
+                } else {
313
+                    dol_print_error($db);
314
+                }
315
+            } else {
316
+                $data = dol_readcachefile($cachedir, $filename);
317
+            }
318
+
319
+            if (! empty($data)) {
320
+                $j=0;
321
+                while ($j < count($data)) {
322
+                    $billurl="search_status=2&amp;paye=1&amp;year=".$data[$j]->annee;
323
+                    $this->info_box_contents[$line][0] = array(
324
+                    'td' => 'align="left" width="16"',
325
+                    'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
326
+                    'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
327
+                    'logo' => 'bill',
328
+                    );
329
+
330
+                    $this->info_box_contents[$line][1] = array(
331
+                    'td' => '',
332
+                    'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee,
333
+                    );
334
+
335
+                    $this->info_box_contents[$line][2] = array(
336
+                    'td' => 'class="right"',
337
+                    'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
338
+                    'text' => $data[$j]->nb,
339
+                    'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
340
+                    );
341
+
342
+                    $this->info_box_contents[$line][3] = array(
343
+                    'td' => 'class="right"',
344
+                    'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency)
345
+                    );
346
+
347
+                    // We add only for the current year
348
+                        $totalnb += $data[$j]->nb;
349
+
350
+                    $this->info_box_contents[$line][4] = array(
351
+                    'td' => 'align="right" width="18"',
352
+                    'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3),
353
+                    );
354
+                    $line++;
355
+                    $j++;
356
+                }
357
+                if (count($data)==0)
358
+                    $this->info_box_contents[$line][0] = array(
359
+                    'td' => 'align="center"',
360
+                    'text'=>$langs->trans("NoRecordedInvoices"),
361
+                    );
362
+            }
363
+
364
+            // part 2
365
+            $cachedir = DOL_DATA_ROOT.'/facture/temp';
366
+            $filename = '/boxactivity-invoice2'.$fileid;
367
+
368
+            $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
369
+
370
+            $data = array();
371
+            if ($refresh) {
372
+                $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
373
+                $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
374
+                $sql.= " WHERE f.entity IN (".getEntity('invoice').')';
375
+                $sql.= " AND f.fk_soc = s.rowid";
376
+                $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0";
377
+                $sql.= " GROUP BY f.fk_statut";
378
+                $sql.= " ORDER BY f.fk_statut DESC";
379
+
380
+                $result = $db->query($sql);
381
+                if ($result) {
382
+                    $num = $db->num_rows($result);
383
+                    $j=0;
384
+                    while ($j < $num) {
385
+                        $data[$j]=$db->fetch_object($result);
386
+                        $j++;
387
+                    }
388
+                    if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
389
+                        dol_filecache($cachedir, $filename, $data);
390
+                    }
391
+                    $db->free($result);
392
+                } else {
393
+                    dol_print_error($db);
394
+                }
395
+            } else {
396
+                $data = dol_readcachefile($cachedir, $filename);
397
+            }
398
+
399
+            if (! empty($data)) {
400
+                $alreadypaid=-1;
401
+
402
+                $j=0;
403
+                while ($j < count($data)) {
404
+                    $billurl="search_status=".$data[$j]->fk_statut."&amp;paye=0";
405
+                    $this->info_box_contents[$line][0] = array(
406
+                    'td' => 'align="left" width="16"',
407
+                    'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
408
+                    'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
409
+                    'logo' => 'bill',
410
+                    );
411
+
412
+                    $this->info_box_contents[$line][1] = array(
413
+                    'td' => '',
414
+                    'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
415
+                    );
416
+
417
+                    $this->info_box_contents[$line][2] = array(
418
+                    'td' => 'class="right"',
419
+                    'text' => $data[$j]->nb,
420
+                    'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
421
+                    'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
422
+                    );
423
+                    $totalnb += $data[$j]->nb;
424
+                    $this->info_box_contents[$line][3] = array(
425
+                    'td' => 'class="right"',
426
+                    'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
427
+                    );
428
+                    $this->info_box_contents[$line][4] = array(
429
+                    'td' => 'align="right" width="18"',
430
+                    'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid),
431
+                    );
432
+                    $line++;
433
+                    $j++;
434
+                }
435
+                if ($num==0)
436
+                    $this->info_box_contents[$line][0] = array(
437
+                    'td' => 'align="center"',
438
+                    'text'=>$langs->trans("NoRecordedInvoices"),
439
+                    );
440
+            }
441 441
         }
442 442
 
443
-		// Add the sum in the bottom of the boxes
444
-		$this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"');
445
-		$this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
446
-		$this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb);
447
-		$this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => '');
448
-		$this->info_box_contents[$line][4] = array('td' => 'align="right" class="liste_total" ', 'text' => "");
443
+        // Add the sum in the bottom of the boxes
444
+        $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"');
445
+        $this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
446
+        $this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb);
447
+        $this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => '');
448
+        $this->info_box_contents[$line][4] = array('td' => 'align="right" class="liste_total" ', 'text' => "");
449 449
     }
450 450
 
451 451
 
452
-	/**
453
-	 *	Method to show box
454
-	 *
455
-	 *	@param	array	$head       Array with properties of box title
456
-	 *	@param  array	$contents   Array with properties of box lines
457
-	 *  @param	int		$nooutput	No print, only return string
458
-	 *	@return	string
459
-	 */
452
+    /**
453
+     *	Method to show box
454
+     *
455
+     *	@param	array	$head       Array with properties of box title
456
+     *	@param  array	$contents   Array with properties of box lines
457
+     *  @param	int		$nooutput	No print, only return string
458
+     *	@return	string
459
+     */
460 460
     function showBox($head = null, $contents = null, $nooutput=0)
461 461
     {
462
-		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
463
-	}
462
+        return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
463
+    }
464 464
 }
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class box_activity extends ModeleBoxes
32 32
 {
33
-    var $boxcode="activity";
34
-    var $boximg="object_bill";
35
-    var $boxlabel='BoxGlobalActivity';
33
+    var $boxcode = "activity";
34
+    var $boximg = "object_bill";
35
+    var $boxlabel = 'BoxGlobalActivity';
36 36
     var $depends = array("facture");
37 37
 
38 38
     /**
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
      *  @param  DoliDB  $db         Database handler
54 54
      *  @param  string  $param      More parameters
55 55
      */
56
-    function __construct($db,$param)
56
+    function __construct($db, $param)
57 57
     {
58 58
         global $conf, $user;
59 59
 
60
-        $this->db=$db;
60
+        $this->db = $db;
61 61
 
62 62
         // FIXME: Pb into some status
63
-        $this->enabled=($conf->global->MAIN_FEATURES_LEVEL);    // Not enabled by default due to bugs (see previous comments)
63
+        $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments)
64 64
 
65
-        $this->hidden= ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire)
66
-            || (! empty($conf->commande->enabled) && $user->rights->commande->lire)
67
-            || (! empty($conf->propal->enabled) && $user->rights->propale->lire)
65
+        $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire)
66
+            || (!empty($conf->commande->enabled) && $user->rights->commande->lire)
67
+            || (!empty($conf->propal->enabled) && $user->rights->propale->lire)
68 68
             );
69 69
     }
70 70
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      *  @param  int     $max        Maximum number of records to load
75 75
      *  @return void
76 76
      */
77
-    function loadBox($max=5)
77
+    function loadBox($max = 5)
78 78
     {
79 79
         global $conf, $user, $langs, $db;
80 80
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
         $totalnb = 0;
85 85
         $line = 0;
86 86
         $cachetime = 3600;
87
-        $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache';
87
+        $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache';
88 88
         $now = dol_now();
89
-        $nbofperiod=3;
89
+        $nbofperiod = 3;
90 90
 
91
-        if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION;
91
+        if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
92 92
         $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod);
93 93
         $this->info_box_head = array(
94 94
             'text' => $textHead,
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
         );
97 97
 
98 98
         // compute the year limit to show
99
-        $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m");
99
+        $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m");
100 100
 
101 101
 
102 102
         // list the summary of the propals
103
-        if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
103
+        if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
104 104
         {
105 105
         	include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
106
-        	$propalstatic=new Propal($db);
106
+        	$propalstatic = new Propal($db);
107 107
 
108 108
         	$cachedir = DOL_DATA_ROOT.'/propale/temp';
109 109
         	$filename = '/boxactivity-propal'.$fileid;
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
         	if ($refresh)
113 113
         	{
114 114
         		$sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
115
-        		$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
116
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
117
-        		$sql.= ")";
118
-        		$sql.= " WHERE p.entity IN (".getEntity('propal').")";
119
-        		$sql.= " AND p.fk_soc = s.rowid";
120
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
121
-        		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
122
-        		$sql.= " AND p.datep >= '".$db->idate($tmpdate)."'";
123
-        		$sql.= " AND p.date_cloture IS NULL"; // just unclosed
124
-        		$sql.= " GROUP BY p.fk_statut";
125
-        		$sql.= " ORDER BY p.fk_statut DESC";
115
+        		$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
116
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
117
+        		$sql .= ")";
118
+        		$sql .= " WHERE p.entity IN (".getEntity('propal').")";
119
+        		$sql .= " AND p.fk_soc = s.rowid";
120
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
121
+        		if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
122
+        		$sql .= " AND p.datep >= '".$db->idate($tmpdate)."'";
123
+        		$sql .= " AND p.date_cloture IS NULL"; // just unclosed
124
+        		$sql .= " GROUP BY p.fk_statut";
125
+        		$sql .= " ORDER BY p.fk_statut DESC";
126 126
 
127 127
         		$result = $db->query($sql);
128 128
         		if ($result)
129 129
         		{
130 130
         			$num = $db->num_rows($result);
131 131
 
132
-        			$j=0;
132
+        			$j = 0;
133 133
         			while ($j < $num) {
134
-        				$data[$j]=$db->fetch_object($result);
134
+        				$data[$j] = $db->fetch_object($result);
135 135
         				$j++;
136 136
         			}
137
-        			if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
137
+        			if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
138 138
         				dol_filecache($cachedir, $filename, $data);
139 139
         			}
140 140
         			$db->free($result);
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
         		$data = dol_readcachefile($cachedir, $filename);
148 148
         	}
149 149
 
150
-        	if (! empty($data))
150
+        	if (!empty($data))
151 151
         	{
152
-        		$j=0;
152
+        		$j = 0;
153 153
         		while ($j < count($data))
154 154
         		{
155 155
         			$this->info_box_contents[$line][0] = array(
156 156
         			'td' => 'align="left" width="16"',
157 157
         			'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
158
-        			'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
158
+        			'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
159 159
         			'logo' => 'object_propal'
160 160
         			);
161 161
 
162 162
         			$this->info_box_contents[$line][1] = array(
163 163
         			'td' => '',
164
-        			'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
164
+        			'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
165 165
         			);
166 166
 
167 167
         			$this->info_box_contents[$line][2] = array(
168 168
         			'td' => 'class="right"',
169 169
         			'text' => $data[$j]->nb,
170
-        			'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
170
+        			'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
171 171
         			'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
172 172
         			);
173 173
         			$totalnb += $data[$j]->nb;
174 174
 
175 175
         			$this->info_box_contents[$line][3] = array(
176 176
         			'td' => 'class="right"',
177
-        			'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
177
+        			'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
178 178
         			);
179 179
         			$this->info_box_contents[$line][4] = array(
180 180
         			'td' => 'align="right" width="18"',
181
-        			'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3),
181
+        			'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
182 182
         			);
183 183
 
184 184
         			$line++;
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
         }
189 189
 
190 190
         // list the summary of the orders
191
-        if (! empty($conf->commande->enabled) && $user->rights->commande->lire) {
191
+        if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
192 192
             include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
193
-            $commandestatic=new Commande($db);
193
+            $commandestatic = new Commande($db);
194 194
 
195 195
             $langs->load("orders");
196 196
 
@@ -202,26 +202,26 @@  discard block
 block discarded – undo
202 202
             if ($refresh) {
203 203
 
204 204
                 $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
205
-                $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
206
-                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
207
-                $sql.= ")";
208
-                $sql.= " WHERE c.entity = ".$conf->entity;
209
-                $sql.= " AND c.fk_soc = s.rowid";
210
-                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
211
-                if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
212
-                $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'";
213
-                $sql.= " GROUP BY c.fk_statut";
214
-                $sql.= " ORDER BY c.fk_statut DESC";
205
+                $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
206
+                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
207
+                $sql .= ")";
208
+                $sql .= " WHERE c.entity = ".$conf->entity;
209
+                $sql .= " AND c.fk_soc = s.rowid";
210
+                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
211
+                if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
212
+                $sql .= " AND c.date_commande >= '".$db->idate($tmpdate)."'";
213
+                $sql .= " GROUP BY c.fk_statut";
214
+                $sql .= " ORDER BY c.fk_statut DESC";
215 215
 
216 216
                 $result = $db->query($sql);
217 217
                 if ($result) {
218 218
                     $num = $db->num_rows($result);
219
-                    $j=0;
219
+                    $j = 0;
220 220
                     while ($j < $num) {
221
-                        $data[$j]=$db->fetch_object($result);
221
+                        $data[$j] = $db->fetch_object($result);
222 222
                         $j++;
223 223
                     }
224
-                    if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
224
+                    if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
225 225
                         dol_filecache($cachedir, $filename, $data);
226 226
                     }
227 227
                     $db->free($result);
@@ -232,36 +232,36 @@  discard block
 block discarded – undo
232 232
                 $data = dol_readcachefile($cachedir, $filename);
233 233
             }
234 234
 
235
-            if (! empty($data)) {
236
-                $j=0;
235
+            if (!empty($data)) {
236
+                $j = 0;
237 237
                 while ($j < count($data)) {
238 238
                     $this->info_box_contents[$line][0] = array(
239 239
                         'td' => 'align="left" width="16"',
240 240
                         'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=".$data[$j]->fk_statut,
241
-                        'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut,0,0),
241
+                        'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
242 242
                         'logo' => 'object_order',
243 243
                     );
244 244
 
245 245
                     $this->info_box_contents[$line][1] = array(
246 246
                         'td' => '',
247
-                        'text' =>$langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut,0,0),
247
+                        'text' =>$langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
248 248
                     );
249 249
 
250 250
                     $this->info_box_contents[$line][2] = array(
251 251
                         'td' => 'class="right"',
252 252
                         'text' => $data[$j]->nb,
253
-                        'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut,0,0),
253
+                        'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
254 254
                         'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=".$data[$j]->fk_statut,
255 255
                     );
256 256
                     $totalnb += $data[$j]->nb;
257 257
 
258 258
                     $this->info_box_contents[$line][3] = array(
259 259
                         'td' => 'class="right"',
260
-                        'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
260
+                        'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
261 261
                     );
262 262
                     $this->info_box_contents[$line][4] = array(
263 263
                         'td' => 'align="right" width="18"',
264
-                        'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3),
264
+                        'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
265 265
                     );
266 266
 
267 267
                     $line++;
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 
273 273
 
274 274
         // list the summary of the bills
275
-        if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
275
+        if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
276 276
         {
277 277
         	include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
278
-        	$facturestatic=new Facture($db);
278
+        	$facturestatic = new Facture($db);
279 279
 
280 280
         	// part 1
281 281
         	$cachedir = DOL_DATA_ROOT.'/facture/temp';
@@ -286,26 +286,26 @@  discard block
 block discarded – undo
286 286
         	if ($refresh)
287 287
         	{
288 288
         		$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
289
-        		$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
290
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
291
-        		$sql.= ")";
292
-        		$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
293
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
294
-        		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
295
-        		$sql.= " AND f.fk_soc = s.rowid";
296
-        		$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1";
297
-        		$sql.= " GROUP BY f.fk_statut";
298
-        		$sql.= " ORDER BY f.fk_statut DESC";
289
+        		$sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
290
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
291
+        		$sql .= ")";
292
+        		$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
293
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
294
+        		if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
295
+        		$sql .= " AND f.fk_soc = s.rowid";
296
+        		$sql .= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1";
297
+        		$sql .= " GROUP BY f.fk_statut";
298
+        		$sql .= " ORDER BY f.fk_statut DESC";
299 299
 
300 300
         		$result = $db->query($sql);
301 301
         		if ($result) {
302 302
         			$num = $db->num_rows($result);
303
-        			$j=0;
303
+        			$j = 0;
304 304
         			while ($j < $num) {
305
-        				$data[$j]=$db->fetch_object($result);
305
+        				$data[$j] = $db->fetch_object($result);
306 306
         				$j++;
307 307
         			}
308
-        			if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
308
+        			if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
309 309
         				dol_filecache($cachedir, $filename, $data);
310 310
         			}
311 311
         			$db->free($result);
@@ -316,32 +316,32 @@  discard block
 block discarded – undo
316 316
         		$data = dol_readcachefile($cachedir, $filename);
317 317
         	}
318 318
 
319
-        	if (! empty($data)) {
320
-        		$j=0;
319
+        	if (!empty($data)) {
320
+        		$j = 0;
321 321
         		while ($j < count($data)) {
322
-        			$billurl="search_status=2&amp;paye=1&amp;year=".$data[$j]->annee;
322
+        			$billurl = "search_status=2&amp;paye=1&amp;year=".$data[$j]->annee;
323 323
         			$this->info_box_contents[$line][0] = array(
324 324
         			'td' => 'align="left" width="16"',
325
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
325
+        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
326 326
         			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
327 327
         			'logo' => 'bill',
328 328
         			);
329 329
 
330 330
         			$this->info_box_contents[$line][1] = array(
331 331
         			'td' => '',
332
-        			'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee,
332
+        			'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee,
333 333
         			);
334 334
 
335 335
         			$this->info_box_contents[$line][2] = array(
336 336
         			'td' => 'class="right"',
337
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
337
+        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
338 338
         			'text' => $data[$j]->nb,
339 339
         			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
340 340
         			);
341 341
 
342 342
         			$this->info_box_contents[$line][3] = array(
343 343
         			'td' => 'class="right"',
344
-        			'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency)
344
+        			'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
345 345
         			);
346 346
 
347 347
         			// We add only for the current year
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 
350 350
         			$this->info_box_contents[$line][4] = array(
351 351
         			'td' => 'align="right" width="18"',
352
-        			'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3),
352
+        			'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
353 353
         			);
354 354
         			$line++;
355 355
         			$j++;
356 356
         		}
357
-        		if (count($data)==0)
357
+        		if (count($data) == 0)
358 358
         			$this->info_box_contents[$line][0] = array(
359 359
         			'td' => 'align="center"',
360 360
         			'text'=>$langs->trans("NoRecordedInvoices"),
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
         	$data = array();
371 371
         	if ($refresh) {
372 372
         		$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
373
-        		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
374
-        		$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
375
-        		$sql.= " AND f.fk_soc = s.rowid";
376
-        		$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0";
377
-        		$sql.= " GROUP BY f.fk_statut";
378
-        		$sql.= " ORDER BY f.fk_statut DESC";
373
+        		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
374
+        		$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
375
+        		$sql .= " AND f.fk_soc = s.rowid";
376
+        		$sql .= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0";
377
+        		$sql .= " GROUP BY f.fk_statut";
378
+        		$sql .= " ORDER BY f.fk_statut DESC";
379 379
 
380 380
         		$result = $db->query($sql);
381 381
         		if ($result) {
382 382
         			$num = $db->num_rows($result);
383
-        			$j=0;
383
+        			$j = 0;
384 384
         			while ($j < $num) {
385
-        				$data[$j]=$db->fetch_object($result);
385
+        				$data[$j] = $db->fetch_object($result);
386 386
         				$j++;
387 387
         			}
388
-        			if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
388
+        			if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
389 389
         				dol_filecache($cachedir, $filename, $data);
390 390
         			}
391 391
         			$db->free($result);
@@ -396,43 +396,43 @@  discard block
 block discarded – undo
396 396
         		$data = dol_readcachefile($cachedir, $filename);
397 397
         	}
398 398
 
399
-        	if (! empty($data)) {
400
-        		$alreadypaid=-1;
399
+        	if (!empty($data)) {
400
+        		$alreadypaid = -1;
401 401
 
402
-        		$j=0;
402
+        		$j = 0;
403 403
         		while ($j < count($data)) {
404
-        			$billurl="search_status=".$data[$j]->fk_statut."&amp;paye=0";
404
+        			$billurl = "search_status=".$data[$j]->fk_statut."&amp;paye=0";
405 405
         			$this->info_box_contents[$line][0] = array(
406 406
         			'td' => 'align="left" width="16"',
407
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
407
+        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
408 408
         			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
409 409
         			'logo' => 'bill',
410 410
         			);
411 411
 
412 412
         			$this->info_box_contents[$line][1] = array(
413 413
         			'td' => '',
414
-        			'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
414
+        			'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
415 415
         			);
416 416
 
417 417
         			$this->info_box_contents[$line][2] = array(
418 418
         			'td' => 'class="right"',
419 419
         			'text' => $data[$j]->nb,
420
-        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
420
+        			'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
421 421
         			'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
422 422
         			);
423 423
         			$totalnb += $data[$j]->nb;
424 424
         			$this->info_box_contents[$line][3] = array(
425 425
         			'td' => 'class="right"',
426
-        			'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
426
+        			'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
427 427
         			);
428 428
         			$this->info_box_contents[$line][4] = array(
429 429
         			'td' => 'align="right" width="18"',
430
-        			'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid),
430
+        			'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
431 431
         			);
432 432
         			$line++;
433 433
         			$j++;
434 434
         		}
435
-        		if ($num==0)
435
+        		if ($num == 0)
436 436
         			$this->info_box_contents[$line][0] = array(
437 437
         			'td' => 'align="center"',
438 438
         			'text'=>$langs->trans("NoRecordedInvoices"),
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 *  @param	int		$nooutput	No print, only return string
458 458
 	 *	@return	string
459 459
 	 */
460
-    function showBox($head = null, $contents = null, $nooutput=0)
460
+    function showBox($head = null, $contents = null, $nooutput = 0)
461 461
     {
462 462
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
463 463
 	}
Please login to merge, or discard this patch.
Braces   +37 added lines, -16 removed lines patch added patch discarded remove patch
@@ -88,7 +88,9 @@  discard block
 block discarded – undo
88 88
         $now = dol_now();
89 89
         $nbofperiod=3;
90 90
 
91
-        if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION;
91
+        if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) {
92
+            $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION;
93
+        }
92 94
         $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod);
93 95
         $this->info_box_head = array(
94 96
             'text' => $textHead,
@@ -113,12 +115,18 @@  discard block
 block discarded – undo
113 115
         	{
114 116
         		$sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
115 117
         		$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
116
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
118
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) {
119
+        		    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
120
+        		}
117 121
         		$sql.= ")";
118 122
         		$sql.= " WHERE p.entity IN (".getEntity('propal').")";
119 123
         		$sql.= " AND p.fk_soc = s.rowid";
120
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
121
-        		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
124
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) {
125
+        		    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
126
+        		}
127
+        		if($user->societe_id) {
128
+        		    $sql.= " AND s.rowid = ".$user->societe_id;
129
+        		}
122 130
         		$sql.= " AND p.datep >= '".$db->idate($tmpdate)."'";
123 131
         		$sql.= " AND p.date_cloture IS NULL"; // just unclosed
124 132
         		$sql.= " GROUP BY p.fk_statut";
@@ -141,8 +149,7 @@  discard block
 block discarded – undo
141 149
         		} else {
142 150
         			dol_print_error($db);
143 151
         		}
144
-        	}
145
-        	else
152
+        	} else
146 153
         	{
147 154
         		$data = dol_readcachefile($cachedir, $filename);
148 155
         	}
@@ -203,12 +210,18 @@  discard block
 block discarded – undo
203 210
 
204 211
                 $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
205 212
                 $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
206
-                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
213
+                if (!$user->rights->societe->client->voir && !$user->societe_id) {
214
+                    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
215
+                }
207 216
                 $sql.= ")";
208 217
                 $sql.= " WHERE c.entity = ".$conf->entity;
209 218
                 $sql.= " AND c.fk_soc = s.rowid";
210
-                if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
211
-                if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
219
+                if (!$user->rights->societe->client->voir && !$user->societe_id) {
220
+                    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
221
+                }
222
+                if($user->societe_id) {
223
+                    $sql.= " AND s.rowid = ".$user->societe_id;
224
+                }
212 225
                 $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'";
213 226
                 $sql.= " GROUP BY c.fk_statut";
214 227
                 $sql.= " ORDER BY c.fk_statut DESC";
@@ -287,11 +300,17 @@  discard block
 block discarded – undo
287 300
         	{
288 301
         		$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
289 302
         		$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
290
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
303
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) {
304
+        		    $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
305
+        		}
291 306
         		$sql.= ")";
292 307
         		$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
293
-        		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
294
-        		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
308
+        		if (!$user->rights->societe->client->voir && !$user->societe_id) {
309
+        		    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
310
+        		}
311
+        		if($user->societe_id) {
312
+        		    $sql.= " AND s.rowid = ".$user->societe_id;
313
+        		}
295 314
         		$sql.= " AND f.fk_soc = s.rowid";
296 315
         		$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1";
297 316
         		$sql.= " GROUP BY f.fk_statut";
@@ -354,11 +373,12 @@  discard block
 block discarded – undo
354 373
         			$line++;
355 374
         			$j++;
356 375
         		}
357
-        		if (count($data)==0)
358
-        			$this->info_box_contents[$line][0] = array(
376
+        		if (count($data)==0) {
377
+        		        			$this->info_box_contents[$line][0] = array(
359 378
         			'td' => 'align="center"',
360 379
         			'text'=>$langs->trans("NoRecordedInvoices"),
361 380
         			);
381
+        		}
362 382
         	}
363 383
 
364 384
         	// part 2
@@ -432,11 +452,12 @@  discard block
 block discarded – undo
432 452
         			$line++;
433 453
         			$j++;
434 454
         		}
435
-        		if ($num==0)
436
-        			$this->info_box_contents[$line][0] = array(
455
+        		if ($num==0) {
456
+        		        			$this->info_box_contents[$line][0] = array(
437 457
         			'td' => 'align="center"',
438 458
         			'text'=>$langs->trans("NoRecordedInvoices"),
439 459
         			);
460
+        		}
440 461
         	}
441 462
         }
442 463
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_produits.php 3 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -33,108 +33,108 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class box_produits extends ModeleBoxes
35 35
 {
36
-	var $boxcode="lastproducts";
37
-	var $boximg="object_product";
38
-	var $boxlabel="BoxLastProducts";
39
-	var $depends = array("produit");
36
+    var $boxcode="lastproducts";
37
+    var $boximg="object_product";
38
+    var $boxlabel="BoxLastProducts";
39
+    var $depends = array("produit");
40 40
 
41
-	/**
41
+    /**
42 42
      * @var DoliDB Database handler.
43 43
      */
44 44
     public $db;
45 45
 
46
-	var $param;
46
+    var $param;
47 47
 
48
-	var $info_box_head = array();
49
-	var $info_box_contents = array();
48
+    var $info_box_head = array();
49
+    var $info_box_contents = array();
50 50
 
51 51
 
52
-	/**
53
-	 *  Constructor
54
-	 *
55
-	 *  @param  DoliDB  $db         Database handler
56
-	 *  @param  string  $param      More parameters
57
-	 */
58
-	function __construct($db,$param)
59
-	{
60
-	    global $conf, $user;
52
+    /**
53
+     *  Constructor
54
+     *
55
+     *  @param  DoliDB  $db         Database handler
56
+     *  @param  string  $param      More parameters
57
+     */
58
+    function __construct($db,$param)
59
+    {
60
+        global $conf, $user;
61 61
 
62
-	    $this->db=$db;
62
+        $this->db=$db;
63 63
 
64
-	    $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
65
-	    $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service');
66
-	    $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
67
-	    $this->hidden=($showmode != 1);
68
-	}
64
+        $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
65
+        $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service');
66
+        $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
67
+        $this->hidden=($showmode != 1);
68
+    }
69 69
 
70
-	/**
71
-	 *  Load data into info_box_contents array to show array later.
72
-	 *
73
-	 *  @param	int		$max        Maximum number of records to load
70
+    /**
71
+     *  Load data into info_box_contents array to show array later.
72
+     *
73
+     *  @param	int		$max        Maximum number of records to load
74 74
      *  @return	void
75
-	 */
76
-	function loadBox($max=5)
77
-	{
78
-		global $user, $langs, $db, $conf, $hookmanager;
79
-
80
-		$this->max=$max;
81
-
82
-		include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
83
-		$productstatic=new Product($db);
84
-
85
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts",$max));
86
-
87
-		if ($user->rights->produit->lire || $user->rights->service->lire)
88
-		{
89
-			$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity";
90
-			$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
91
-			$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
92
-			if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
93
-			if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
94
-			// Add where from hooks
95
-			if (is_object($hookmanager))
96
-			{
97
-			    $parameters=array('boxproductlist'=>1);
98
-			    $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
99
-			    $sql.=$hookmanager->resPrint;
100
-			}
101
-			$sql.= $db->order('p.datec', 'DESC');
102
-			$sql.= $db->plimit($max, 0);
103
-
104
-			$result = $db->query($sql);
105
-			if ($result)
106
-			{
107
-				$num = $db->num_rows($result);
108
-				$line = 0;
109
-				while ($line < $num)
110
-				{
111
-					$objp = $db->fetch_object($result);
112
-					$datem=$db->jdate($objp->tms);
113
-
114
-					// Multilangs
115
-					if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
116
-					{
117
-						$sqld = "SELECT label";
118
-						$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
119
-						$sqld.= " WHERE fk_product=".$objp->rowid;
120
-						$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
121
-						$sqld.= " LIMIT 1";
122
-
123
-						$resultd = $db->query($sqld);
124
-						if ($resultd)
125
-						{
126
-							$objtp = $db->fetch_object($resultd);
127
-							if (isset($objtp->label) && $objtp->label != '')
128
-								$objp->label = $objtp->label;
129
-						}
130
-					}
75
+     */
76
+    function loadBox($max=5)
77
+    {
78
+        global $user, $langs, $db, $conf, $hookmanager;
79
+
80
+        $this->max=$max;
81
+
82
+        include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
83
+        $productstatic=new Product($db);
84
+
85
+        $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts",$max));
86
+
87
+        if ($user->rights->produit->lire || $user->rights->service->lire)
88
+        {
89
+            $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity";
90
+            $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
91
+            $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
92
+            if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
93
+            if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
94
+            // Add where from hooks
95
+            if (is_object($hookmanager))
96
+            {
97
+                $parameters=array('boxproductlist'=>1);
98
+                $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
99
+                $sql.=$hookmanager->resPrint;
100
+            }
101
+            $sql.= $db->order('p.datec', 'DESC');
102
+            $sql.= $db->plimit($max, 0);
103
+
104
+            $result = $db->query($sql);
105
+            if ($result)
106
+            {
107
+                $num = $db->num_rows($result);
108
+                $line = 0;
109
+                while ($line < $num)
110
+                {
111
+                    $objp = $db->fetch_object($result);
112
+                    $datem=$db->jdate($objp->tms);
113
+
114
+                    // Multilangs
115
+                    if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
116
+                    {
117
+                        $sqld = "SELECT label";
118
+                        $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
119
+                        $sqld.= " WHERE fk_product=".$objp->rowid;
120
+                        $sqld.= " AND lang='". $langs->getDefaultLang() ."'";
121
+                        $sqld.= " LIMIT 1";
122
+
123
+                        $resultd = $db->query($sqld);
124
+                        if ($resultd)
125
+                        {
126
+                            $objtp = $db->fetch_object($resultd);
127
+                            if (isset($objtp->label) && $objtp->label != '')
128
+                                $objp->label = $objtp->label;
129
+                        }
130
+                    }
131 131
                     $productstatic->id = $objp->rowid;
132 132
                     $productstatic->ref = $objp->ref;
133 133
                     $productstatic->type = $objp->fk_product_type;
134 134
                     $productstatic->label = $objp->label;
135
-					$productstatic->entity = $objp->entity;
135
+                    $productstatic->entity = $objp->entity;
136 136
 
137
-					$this->info_box_contents[$line][] = array(
137
+                    $this->info_box_contents[$line][] = array(
138 138
                         'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
139 139
                         'text' => $productstatic->getNomUrl(1),
140 140
                         'asis' => 1,
@@ -148,50 +148,50 @@  discard block
 block discarded – undo
148 148
                     if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
149 149
                         $price_base_type=$langs->trans($objp->price_base_type);
150 150
                         $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
151
-	                }
152
-	                else //Parse the dynamic price
153
-	               	{
154
-						$productstatic->fetch($objp->rowid, '', '', 1);
155
-	                    $priceparser = new PriceParser($this->db);
156
-	                    $price_result = $priceparser->parseProduct($productstatic);
157
-	                    if ($price_result >= 0) {
158
-							if ($objp->price_base_type == 'HT')
159
-							{
160
-								$price_base_type=$langs->trans("HT");
161
-							}
162
-							else
163
-							{
164
-								$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
165
-								$price_base_type=$langs->trans("TTC");
166
-							}
167
-							$price=price($price_result);
168
-	                    }
169
-	               	}
170
-					$this->info_box_contents[$line][] = array(
151
+                    }
152
+                    else //Parse the dynamic price
153
+                        {
154
+                        $productstatic->fetch($objp->rowid, '', '', 1);
155
+                        $priceparser = new PriceParser($this->db);
156
+                        $price_result = $priceparser->parseProduct($productstatic);
157
+                        if ($price_result >= 0) {
158
+                            if ($objp->price_base_type == 'HT')
159
+                            {
160
+                                $price_base_type=$langs->trans("HT");
161
+                            }
162
+                            else
163
+                            {
164
+                                $price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
165
+                                $price_base_type=$langs->trans("TTC");
166
+                            }
167
+                            $price=price($price_result);
168
+                        }
169
+                        }
170
+                    $this->info_box_contents[$line][] = array(
171 171
                         'td' => 'class="right"',
172 172
                         'text' => $price,
173 173
                     );
174 174
 
175
-					$this->info_box_contents[$line][] = array(
175
+                    $this->info_box_contents[$line][] = array(
176 176
                         'td' => 'class="nowrap"',
177 177
                         'text' => $price_base_type,
178 178
                     );
179 179
 
180
-					$this->info_box_contents[$line][] = array(
180
+                    $this->info_box_contents[$line][] = array(
181 181
                         'td' => 'class="right"',
182 182
                         'text' => dol_print_date($datem,'day'),
183 183
                     );
184 184
 
185
-					$this->info_box_contents[$line][] = array(
185
+                    $this->info_box_contents[$line][] = array(
186 186
                         'td' => 'align="right" width="18"',
187 187
                         'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>',
188
-					    'asis' => 1
188
+                        'asis' => 1
189 189
                     );
190 190
 
191 191
                     $this->info_box_contents[$line][] = array(
192 192
                         'td' => 'align="right" width="18"',
193 193
                         'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy,3,1).'</span>',
194
-					    'asis' => 1
194
+                        'asis' => 1
195 195
                     );
196 196
 
197 197
                     $line++;
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
         }
219 219
     }
220 220
 
221
-	/**
222
-	 *	Method to show box
223
-	 *
224
-	 *	@param	array	$head       Array with properties of box title
225
-	 *	@param  array	$contents   Array with properties of box lines
226
-	 *  @param	int		$nooutput	No print, only return string
227
-	 *	@return	string
228
-	 */
221
+    /**
222
+     *	Method to show box
223
+     *
224
+     *	@param	array	$head       Array with properties of box title
225
+     *	@param  array	$contents   Array with properties of box lines
226
+     *  @param	int		$nooutput	No print, only return string
227
+     *	@return	string
228
+     */
229 229
     function showBox($head = null, $contents = null, $nooutput=0)
230 230
     {
231
-		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
232
-	}
231
+        return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
232
+    }
233 233
 }
234 234
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class box_produits extends ModeleBoxes
35 35
 {
36
-	var $boxcode="lastproducts";
37
-	var $boximg="object_product";
38
-	var $boxlabel="BoxLastProducts";
36
+	var $boxcode = "lastproducts";
37
+	var $boximg = "object_product";
38
+	var $boxlabel = "BoxLastProducts";
39 39
 	var $depends = array("produit");
40 40
 
41 41
 	/**
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
 	 *  @param  DoliDB  $db         Database handler
56 56
 	 *  @param  string  $param      More parameters
57 57
 	 */
58
-	function __construct($db,$param)
58
+	function __construct($db, $param)
59 59
 	{
60 60
 	    global $conf, $user;
61 61
 
62
-	    $this->db=$db;
62
+	    $this->db = $db;
63 63
 
64
-	    $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
65
-	    $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service');
66
-	    $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
67
-	    $this->hidden=($showmode != 1);
64
+	    $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
65
+	    $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service');
66
+	    $showmode = isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
67
+	    $this->hidden = ($showmode != 1);
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,33 +73,33 @@  discard block
 block discarded – undo
73 73
 	 *  @param	int		$max        Maximum number of records to load
74 74
      *  @return	void
75 75
 	 */
76
-	function loadBox($max=5)
76
+	function loadBox($max = 5)
77 77
 	{
78 78
 		global $user, $langs, $db, $conf, $hookmanager;
79 79
 
80
-		$this->max=$max;
80
+		$this->max = $max;
81 81
 
82 82
 		include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
83
-		$productstatic=new Product($db);
83
+		$productstatic = new Product($db);
84 84
 
85
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts",$max));
85
+		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max));
86 86
 
87 87
 		if ($user->rights->produit->lire || $user->rights->service->lire)
88 88
 		{
89 89
 			$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity";
90
-			$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
91
-			$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
92
-			if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
93
-			if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
90
+			$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
91
+			$sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
92
+			if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0';
93
+			if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1';
94 94
 			// Add where from hooks
95 95
 			if (is_object($hookmanager))
96 96
 			{
97
-			    $parameters=array('boxproductlist'=>1);
98
-			    $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
99
-			    $sql.=$hookmanager->resPrint;
97
+			    $parameters = array('boxproductlist'=>1);
98
+			    $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
99
+			    $sql .= $hookmanager->resPrint;
100 100
 			}
101
-			$sql.= $db->order('p.datec', 'DESC');
102
-			$sql.= $db->plimit($max, 0);
101
+			$sql .= $db->order('p.datec', 'DESC');
102
+			$sql .= $db->plimit($max, 0);
103 103
 
104 104
 			$result = $db->query($sql);
105 105
 			if ($result)
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 				while ($line < $num)
110 110
 				{
111 111
 					$objp = $db->fetch_object($result);
112
-					$datem=$db->jdate($objp->tms);
112
+					$datem = $db->jdate($objp->tms);
113 113
 
114 114
 					// Multilangs
115
-					if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
115
+					if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
116 116
 					{
117 117
 						$sqld = "SELECT label";
118
-						$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
119
-						$sqld.= " WHERE fk_product=".$objp->rowid;
120
-						$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
121
-						$sqld.= " LIMIT 1";
118
+						$sqld .= " FROM ".MAIN_DB_PREFIX."product_lang";
119
+						$sqld .= " WHERE fk_product=".$objp->rowid;
120
+						$sqld .= " AND lang='".$langs->getDefaultLang()."'";
121
+						$sqld .= " LIMIT 1";
122 122
 
123 123
 						$resultd = $db->query($sqld);
124 124
 						if ($resultd)
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
                     );
147 147
 
148 148
                     if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
149
-                        $price_base_type=$langs->trans($objp->price_base_type);
150
-                        $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
149
+                        $price_base_type = $langs->trans($objp->price_base_type);
150
+                        $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc);
151 151
 	                }
152 152
 	                else //Parse the dynamic price
153 153
 	               	{
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 	                    if ($price_result >= 0) {
158 158
 							if ($objp->price_base_type == 'HT')
159 159
 							{
160
-								$price_base_type=$langs->trans("HT");
160
+								$price_base_type = $langs->trans("HT");
161 161
 							}
162 162
 							else
163 163
 							{
164 164
 								$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
165
-								$price_base_type=$langs->trans("TTC");
165
+								$price_base_type = $langs->trans("TTC");
166 166
 							}
167
-							$price=price($price_result);
167
+							$price = price($price_result);
168 168
 	                    }
169 169
 	               	}
170 170
 					$this->info_box_contents[$line][] = array(
@@ -179,24 +179,24 @@  discard block
 block discarded – undo
179 179
 
180 180
 					$this->info_box_contents[$line][] = array(
181 181
                         'td' => 'class="right"',
182
-                        'text' => dol_print_date($datem,'day'),
182
+                        'text' => dol_print_date($datem, 'day'),
183 183
                     );
184 184
 
185 185
 					$this->info_box_contents[$line][] = array(
186 186
                         'td' => 'align="right" width="18"',
187
-                        'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>',
187
+                        'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell, 3, 0).'<span>',
188 188
 					    'asis' => 1
189 189
                     );
190 190
 
191 191
                     $this->info_box_contents[$line][] = array(
192 192
                         'td' => 'align="right" width="18"',
193
-                        'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy,3,1).'</span>',
193
+                        'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy, 3, 1).'</span>',
194 194
 					    'asis' => 1
195 195
                     );
196 196
 
197 197
                     $line++;
198 198
                 }
199
-                if ($num==0)
199
+                if ($num == 0)
200 200
                     $this->info_box_contents[$line][0] = array(
201 201
                         'td' => 'align="center"',
202 202
                         'text'=>$langs->trans("NoRecordedProducts"),
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 *  @param	int		$nooutput	No print, only return string
227 227
 	 *	@return	string
228 228
 	 */
229
-    function showBox($head = null, $contents = null, $nooutput=0)
229
+    function showBox($head = null, $contents = null, $nooutput = 0)
230 230
     {
231 231
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
232 232
 	}
Please login to merge, or discard this patch.
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -89,8 +89,12 @@  discard block
 block discarded – undo
89 89
 			$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity";
90 90
 			$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
91 91
 			$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
92
-			if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
93
-			if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
92
+			if (empty($user->rights->produit->lire)) {
93
+			    $sql.=' AND p.fk_product_type != 0';
94
+			}
95
+			if (empty($user->rights->service->lire)) {
96
+			    $sql.=' AND p.fk_product_type != 1';
97
+			}
94 98
 			// Add where from hooks
95 99
 			if (is_object($hookmanager))
96 100
 			{
@@ -112,9 +116,11 @@  discard block
 block discarded – undo
112 116
 					$datem=$db->jdate($objp->tms);
113 117
 
114 118
 					// Multilangs
115
-					if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
119
+					if (! empty($conf->global->MAIN_MULTILANGS)) {
120
+					    // si l'option est active
116 121
 					{
117 122
 						$sqld = "SELECT label";
123
+					}
118 124
 						$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
119 125
 						$sqld.= " WHERE fk_product=".$objp->rowid;
120 126
 						$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
@@ -124,8 +130,9 @@  discard block
 block discarded – undo
124 130
 						if ($resultd)
125 131
 						{
126 132
 							$objtp = $db->fetch_object($resultd);
127
-							if (isset($objtp->label) && $objtp->label != '')
128
-								$objp->label = $objtp->label;
133
+							if (isset($objtp->label) && $objtp->label != '') {
134
+															$objp->label = $objtp->label;
135
+							}
129 136
 						}
130 137
 					}
131 138
                     $productstatic->id = $objp->rowid;
@@ -148,8 +155,7 @@  discard block
 block discarded – undo
148 155
                     if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
149 156
                         $price_base_type=$langs->trans($objp->price_base_type);
150 157
                         $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
151
-	                }
152
-	                else //Parse the dynamic price
158
+	                } else //Parse the dynamic price
153 159
 	               	{
154 160
 						$productstatic->fetch($objp->rowid, '', '', 1);
155 161
 	                    $priceparser = new PriceParser($this->db);
@@ -158,8 +164,7 @@  discard block
 block discarded – undo
158 164
 							if ($objp->price_base_type == 'HT')
159 165
 							{
160 166
 								$price_base_type=$langs->trans("HT");
161
-							}
162
-							else
167
+							} else
163 168
 							{
164 169
 								$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
165 170
 								$price_base_type=$langs->trans("TTC");
@@ -196,11 +201,12 @@  discard block
 block discarded – undo
196 201
 
197 202
                     $line++;
198 203
                 }
199
-                if ($num==0)
200
-                    $this->info_box_contents[$line][0] = array(
204
+                if ($num==0) {
205
+                                    $this->info_box_contents[$line][0] = array(
201 206
                         'td' => 'align="center"',
202 207
                         'text'=>$langs->trans("NoRecordedProducts"),
203 208
                     );
209
+                }
204 210
 
205 211
                 $db->free($result);
206 212
             } else {
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_graph_product_distribution.php 3 patches
Indentation   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -29,392 +29,392 @@
 block discarded – undo
29 29
  */
30 30
 class box_graph_product_distribution extends ModeleBoxes
31 31
 {
32
-	var $boxcode="productdistribution";
33
-	var $boximg="object_product";
34
-	var $boxlabel="BoxProductDistribution";
35
-	var $depends = array("product|service","facture|propal|commande");
32
+    var $boxcode="productdistribution";
33
+    var $boximg="object_product";
34
+    var $boxlabel="BoxProductDistribution";
35
+    var $depends = array("product|service","facture|propal|commande");
36 36
 
37
-	/**
37
+    /**
38 38
      * @var DoliDB Database handler.
39 39
      */
40 40
     public $db;
41 41
     
42
-	var $param;
43
-
44
-	var $info_box_head = array();
45
-	var $info_box_contents = array();
46
-
47
-
48
-	/**
49
-	 *  Constructor
50
-	 *
51
-	 * 	@param	DoliDB	$db			Database handler
52
-	 *  @param	string	$param		More parameters
53
-	 */
54
-	function __construct($db,$param)
55
-	{
56
-		global $user, $conf;
57
-
58
-		$this->db=$db;
59
-
60
-		$this->hidden = ! (
61
-		    (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
62
-		 || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
63
-		 || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
64
-		);
65
-	}
66
-
67
-	/**
68
-	 *  Load data into info_box_contents array to show array later.
69
-	 *
70
-	 *  @param	int		$max        Maximum number of records to load
42
+    var $param;
43
+
44
+    var $info_box_head = array();
45
+    var $info_box_contents = array();
46
+
47
+
48
+    /**
49
+     *  Constructor
50
+     *
51
+     * 	@param	DoliDB	$db			Database handler
52
+     *  @param	string	$param		More parameters
53
+     */
54
+    function __construct($db,$param)
55
+    {
56
+        global $user, $conf;
57
+
58
+        $this->db=$db;
59
+
60
+        $this->hidden = ! (
61
+            (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
62
+         || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
63
+         || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
64
+        );
65
+    }
66
+
67
+    /**
68
+     *  Load data into info_box_contents array to show array later.
69
+     *
70
+     *  @param	int		$max        Maximum number of records to load
71 71
      *  @return	void
72
-	 */
73
-	function loadBox($max=5)
74
-	{
75
-		global $conf, $user, $langs, $db;
76
-
77
-		$this->max=$max;
78
-
79
-		$refreshaction='refresh_'.$this->boxcode;
80
-
81
-		include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
82
-		include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
83
-		include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
84
-
85
-		$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
86
-		$param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
87
-		$param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
88
-		$param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
89
-		$autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
90
-		if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
91
-		{
92
-			$year=GETPOST($param_year,'int');
93
-			$showinvoicenb=GETPOST($param_showinvoicenb,'alpha');
94
-			$showpropalnb=GETPOST($param_showpropalnb,'alpha');
95
-			$showordernb=GETPOST($param_showordernb,'alpha');
96
-		}
97
-		else
98
-		{
99
-			$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
100
-			$year=$tmparray['year'];
101
-			$showinvoicenb=$tmparray['showinvoicenb'];
102
-			$showpropalnb=$tmparray['showpropalnb'];
103
-			$showordernb=$tmparray['showordernb'];
104
-		}
105
-		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
106
-		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
107
-		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
108
-		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
109
-
110
-		$nowarray=dol_getdate(dol_now(),true);
111
-		if (empty($year)) $year=$nowarray['year'];
112
-
113
-		$nbofgraph=0;
114
-		if ($showinvoicenb) $nbofgraph++;
115
-		if ($showpropalnb)  $nbofgraph++;
116
-		if ($showordernb)   $nbofgraph++;
117
-
118
-		$text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year;
119
-		$this->info_box_head = array(
120
-				'text' => $text,
121
-				'limit'=> dol_strlen($text),
122
-				'graph'=> 1,
123
-				'sublink'=>'',
124
-				'subtext'=>$langs->trans("Filter"),
125
-				'subpicto'=>'filter.png',
126
-				'subclass'=>'linkobject boxfilter',
127
-				'target'=>'none'	// Set '' to get target="_blank"
128
-		);
129
-
130
-
131
-		$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
132
-		if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
133
-		if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
134
-
135
-		$socid=empty($user->societe_id)?0:$user->societe_id;
136
-		$userid=0;	// No filter on user creation
137
-
138
-		$WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
139
-		$HEIGHT='192';
140
-
141
-		if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
142
-		{
143
-			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
144
-			if ($showinvoicenb)
145
-			{
72
+     */
73
+    function loadBox($max=5)
74
+    {
75
+        global $conf, $user, $langs, $db;
76
+
77
+        $this->max=$max;
78
+
79
+        $refreshaction='refresh_'.$this->boxcode;
80
+
81
+        include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
82
+        include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
83
+        include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
84
+
85
+        $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
86
+        $param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
87
+        $param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
88
+        $param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
89
+        $autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
90
+        if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
91
+        {
92
+            $year=GETPOST($param_year,'int');
93
+            $showinvoicenb=GETPOST($param_showinvoicenb,'alpha');
94
+            $showpropalnb=GETPOST($param_showpropalnb,'alpha');
95
+            $showordernb=GETPOST($param_showordernb,'alpha');
96
+        }
97
+        else
98
+        {
99
+            $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
100
+            $year=$tmparray['year'];
101
+            $showinvoicenb=$tmparray['showinvoicenb'];
102
+            $showpropalnb=$tmparray['showpropalnb'];
103
+            $showordernb=$tmparray['showordernb'];
104
+        }
105
+        if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
106
+        if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
107
+        if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
108
+        if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
109
+
110
+        $nowarray=dol_getdate(dol_now(),true);
111
+        if (empty($year)) $year=$nowarray['year'];
112
+
113
+        $nbofgraph=0;
114
+        if ($showinvoicenb) $nbofgraph++;
115
+        if ($showpropalnb)  $nbofgraph++;
116
+        if ($showordernb)   $nbofgraph++;
117
+
118
+        $text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year;
119
+        $this->info_box_head = array(
120
+                'text' => $text,
121
+                'limit'=> dol_strlen($text),
122
+                'graph'=> 1,
123
+                'sublink'=>'',
124
+                'subtext'=>$langs->trans("Filter"),
125
+                'subpicto'=>'filter.png',
126
+                'subclass'=>'linkobject boxfilter',
127
+                'target'=>'none'	// Set '' to get target="_blank"
128
+        );
129
+
130
+
131
+        $paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
132
+        if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
133
+        if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
134
+
135
+        $socid=empty($user->societe_id)?0:$user->societe_id;
136
+        $userid=0;	// No filter on user creation
137
+
138
+        $WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
139
+        $HEIGHT='192';
140
+
141
+        if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
142
+        {
143
+            // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
144
+            if ($showinvoicenb)
145
+            {
146 146
                 $langs->load("bills");
147
-				include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
148
-
149
-				$showpointvalue = 1; $nocolor = 0;
150
-				$mode='customer';
151
-				$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0));
152
-				$data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
153
-				if (empty($data1))
154
-				{
155
-					$showpointvalue=0;
156
-					$nocolor=1;
157
-					$data1=array(array(0=>$langs->trans("None"),1=>1));
158
-				}
159
-				$filenamenb = $dir."/prodserforinvoice-".$year.".png";
160
-				$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&amp;file=prodserforinvoice-'.$year.'.png';
161
-
162
-				$px1 = new DolGraph();
163
-				$mesg = $px1->isGraphKo();
164
-				if (! $mesg)
165
-				{
166
-					$i=0;$tot=count($data1);$legend=array();
167
-					while ($i <= $tot)
168
-					{
169
-						$data1[$i][0]=dol_trunc($data1[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
170
-						$legend[]=$data1[$i][0];
171
-						$i++;
172
-					}
173
-
174
-					$px1->SetData($data1);
175
-					unset($data1);
176
-
177
-					if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
178
-					$px1->SetPrecisionY(0);
179
-					$px1->SetLegend($legend);
180
-					$px1->setShowLegend(0);
181
-					$px1->setShowPointValue($showpointvalue);
182
-					$px1->setShowPercent(0);
183
-					$px1->SetMaxValue($px1->GetCeilMaxValue());
184
-					$px1->SetWidth($WIDTH);
185
-					$px1->SetHeight($HEIGHT);
186
-					//$px1->SetYLabel($langs->trans("NumberOfBills"));
187
-					$px1->SetShading(3);
188
-					$px1->SetHorizTickIncrement(1);
189
-					$px1->SetPrecisionY(0);
190
-					$px1->SetCssPrefix("cssboxes");
191
-					//$px1->mode='depth';
192
-					$px1->SetType(array('pie'));
193
-					$px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices")));
194
-					$px1->combine = 0.05;
195
-
196
-					$px1->draw($filenamenb,$fileurlnb);
197
-				}
198
-			}
199
-		}
200
-
201
-		if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
202
-		{
203
-			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
204
-			if ($showpropalnb)
205
-			{
147
+                include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
148
+
149
+                $showpointvalue = 1; $nocolor = 0;
150
+                $mode='customer';
151
+                $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0));
152
+                $data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
153
+                if (empty($data1))
154
+                {
155
+                    $showpointvalue=0;
156
+                    $nocolor=1;
157
+                    $data1=array(array(0=>$langs->trans("None"),1=>1));
158
+                }
159
+                $filenamenb = $dir."/prodserforinvoice-".$year.".png";
160
+                $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&amp;file=prodserforinvoice-'.$year.'.png';
161
+
162
+                $px1 = new DolGraph();
163
+                $mesg = $px1->isGraphKo();
164
+                if (! $mesg)
165
+                {
166
+                    $i=0;$tot=count($data1);$legend=array();
167
+                    while ($i <= $tot)
168
+                    {
169
+                        $data1[$i][0]=dol_trunc($data1[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
170
+                        $legend[]=$data1[$i][0];
171
+                        $i++;
172
+                    }
173
+
174
+                    $px1->SetData($data1);
175
+                    unset($data1);
176
+
177
+                    if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
178
+                    $px1->SetPrecisionY(0);
179
+                    $px1->SetLegend($legend);
180
+                    $px1->setShowLegend(0);
181
+                    $px1->setShowPointValue($showpointvalue);
182
+                    $px1->setShowPercent(0);
183
+                    $px1->SetMaxValue($px1->GetCeilMaxValue());
184
+                    $px1->SetWidth($WIDTH);
185
+                    $px1->SetHeight($HEIGHT);
186
+                    //$px1->SetYLabel($langs->trans("NumberOfBills"));
187
+                    $px1->SetShading(3);
188
+                    $px1->SetHorizTickIncrement(1);
189
+                    $px1->SetPrecisionY(0);
190
+                    $px1->SetCssPrefix("cssboxes");
191
+                    //$px1->mode='depth';
192
+                    $px1->SetType(array('pie'));
193
+                    $px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices")));
194
+                    $px1->combine = 0.05;
195
+
196
+                    $px1->draw($filenamenb,$fileurlnb);
197
+                }
198
+            }
199
+        }
200
+
201
+        if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
202
+        {
203
+            // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
204
+            if ($showpropalnb)
205
+            {
206 206
                 $langs->load("propal");
207
-				include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
208
-
209
-				$showpointvalue = 1; $nocolor = 0;
210
-				$stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0));
211
-				$data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
212
-				if (empty($data2))
213
-				{
214
-					$showpointvalue = 0;
215
-					$nocolor = 1;
216
-					$data2=array(array(0=>$langs->trans("None"),1=>1));
217
-				}
218
-
219
-				$filenamenb = $dir."/prodserforpropal-".$year.".png";
220
-				$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=proposalstats&amp;file=prodserforpropal-'.$year.'.png';
221
-
222
-				$px2 = new DolGraph();
223
-				$mesg = $px2->isGraphKo();
224
-				if (! $mesg)
225
-				{
226
-					$i=0;$tot=count($data2);$legend=array();
227
-					while ($i <= $tot)
228
-					{
229
-						$data2[$i][0]=dol_trunc($data2[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
230
-						$legend[]=$data2[$i][0];
231
-						$i++;
232
-					}
233
-
234
-					$px2->SetData($data2);
235
-					unset($data2);
236
-
237
-					if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
238
-					$px2->SetPrecisionY(0);
239
-					$px2->SetLegend($legend);
240
-					$px2->setShowLegend(0);
241
-					$px2->setShowPointValue($showpointvalue);
242
-					$px2->setShowPercent(0);
243
-					$px2->SetMaxValue($px2->GetCeilMaxValue());
244
-					$px2->SetWidth($WIDTH);
245
-					$px2->SetHeight($HEIGHT);
246
-					//$px2->SetYLabel($langs->trans("AmountOfBillsHT"));
247
-					$px2->SetShading(3);
248
-					$px2->SetHorizTickIncrement(1);
249
-					$px2->SetPrecisionY(0);
250
-					$px2->SetCssPrefix("cssboxes");
251
-					//$px2->mode='depth';
252
-					$px2->SetType(array('pie'));
253
-					$px2->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Proposals")));
254
-					$px2->combine = 0.05;
255
-
256
-					$px2->draw($filenamenb,$fileurlnb);
257
-				}
258
-			}
259
-		}
260
-
261
-		if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
262
-		{
263
-			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
264
-			if ($showordernb)
265
-			{
266
-			    $langs->load("orders");
267
-				include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
268
-
269
-				$showpointvalue = 1; $nocolor = 0;
270
-				$mode='customer';
271
-				$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0));
272
-				$data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
273
-				if (empty($data3))
274
-				{
275
-					$showpointvalue = 0;
276
-					$nocolor = 1;
277
-					$data3=array(array(0=>$langs->trans("None"),1=>1));
278
-				}
279
-
280
-				$filenamenb = $dir."/prodserfororder-".$year.".png";
281
-				$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=prodserfororder-'.$year.'.png';
282
-
283
-				$px3 = new DolGraph();
284
-				$mesg = $px3->isGraphKo();
285
-				if (! $mesg)
286
-				{
287
-					$i=0;$tot=count($data3);$legend=array();
288
-					while ($i <= $tot)
289
-					{
290
-						$data3[$i][0]=dol_trunc($data3[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
291
-						$legend[]=$data3[$i][0];
292
-						$i++;
293
-					}
294
-
295
-					$px3->SetData($data3);
296
-					unset($data3);
297
-
298
-					if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
299
-					$px3->SetPrecisionY(0);
300
-					$px3->SetLegend($legend);
301
-					$px3->setShowLegend(0);
302
-					$px3->setShowPointValue($showpointvalue);
303
-					$px3->setShowPercent(0);
304
-					$px3->SetMaxValue($px3->GetCeilMaxValue());
305
-					$px3->SetWidth($WIDTH);
306
-					$px3->SetHeight($HEIGHT);
307
-					//$px3->SetYLabel($langs->trans("AmountOfBillsHT"));
308
-					$px3->SetShading(3);
309
-					$px3->SetHorizTickIncrement(1);
310
-					$px3->SetPrecisionY(0);
311
-					$px3->SetCssPrefix("cssboxes");
312
-					//$px3->mode='depth';
313
-					$px3->SetType(array('pie'));
314
-					$px3->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Orders")));
315
-					$px3->combine = 0.05;
316
-
317
-					$px3->draw($filenamenb,$fileurlnb);
318
-				}
319
-			}
320
-		}
321
-
322
-		if (empty($nbofgraph))
323
-		{
324
-		    $langs->load("errors");
325
-		    $mesg=$langs->trans("ReadPermissionNotAllowed");
326
-		}
327
-		if (empty($conf->use_javascript_ajax))
328
-		{
329
-			$langs->load("errors");
330
-			$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
331
-		}
332
-
333
-		if (! $mesg)
334
-		{
335
-			$stringtoshow='';
336
-			$stringtoshow.='<script type="text/javascript" language="javascript">
207
+                include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
208
+
209
+                $showpointvalue = 1; $nocolor = 0;
210
+                $stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0));
211
+                $data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
212
+                if (empty($data2))
213
+                {
214
+                    $showpointvalue = 0;
215
+                    $nocolor = 1;
216
+                    $data2=array(array(0=>$langs->trans("None"),1=>1));
217
+                }
218
+
219
+                $filenamenb = $dir."/prodserforpropal-".$year.".png";
220
+                $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=proposalstats&amp;file=prodserforpropal-'.$year.'.png';
221
+
222
+                $px2 = new DolGraph();
223
+                $mesg = $px2->isGraphKo();
224
+                if (! $mesg)
225
+                {
226
+                    $i=0;$tot=count($data2);$legend=array();
227
+                    while ($i <= $tot)
228
+                    {
229
+                        $data2[$i][0]=dol_trunc($data2[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
230
+                        $legend[]=$data2[$i][0];
231
+                        $i++;
232
+                    }
233
+
234
+                    $px2->SetData($data2);
235
+                    unset($data2);
236
+
237
+                    if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
238
+                    $px2->SetPrecisionY(0);
239
+                    $px2->SetLegend($legend);
240
+                    $px2->setShowLegend(0);
241
+                    $px2->setShowPointValue($showpointvalue);
242
+                    $px2->setShowPercent(0);
243
+                    $px2->SetMaxValue($px2->GetCeilMaxValue());
244
+                    $px2->SetWidth($WIDTH);
245
+                    $px2->SetHeight($HEIGHT);
246
+                    //$px2->SetYLabel($langs->trans("AmountOfBillsHT"));
247
+                    $px2->SetShading(3);
248
+                    $px2->SetHorizTickIncrement(1);
249
+                    $px2->SetPrecisionY(0);
250
+                    $px2->SetCssPrefix("cssboxes");
251
+                    //$px2->mode='depth';
252
+                    $px2->SetType(array('pie'));
253
+                    $px2->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Proposals")));
254
+                    $px2->combine = 0.05;
255
+
256
+                    $px2->draw($filenamenb,$fileurlnb);
257
+                }
258
+            }
259
+        }
260
+
261
+        if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
262
+        {
263
+            // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
264
+            if ($showordernb)
265
+            {
266
+                $langs->load("orders");
267
+                include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
268
+
269
+                $showpointvalue = 1; $nocolor = 0;
270
+                $mode='customer';
271
+                $stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0));
272
+                $data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
273
+                if (empty($data3))
274
+                {
275
+                    $showpointvalue = 0;
276
+                    $nocolor = 1;
277
+                    $data3=array(array(0=>$langs->trans("None"),1=>1));
278
+                }
279
+
280
+                $filenamenb = $dir."/prodserfororder-".$year.".png";
281
+                $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=prodserfororder-'.$year.'.png';
282
+
283
+                $px3 = new DolGraph();
284
+                $mesg = $px3->isGraphKo();
285
+                if (! $mesg)
286
+                {
287
+                    $i=0;$tot=count($data3);$legend=array();
288
+                    while ($i <= $tot)
289
+                    {
290
+                        $data3[$i][0]=dol_trunc($data3[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
291
+                        $legend[]=$data3[$i][0];
292
+                        $i++;
293
+                    }
294
+
295
+                    $px3->SetData($data3);
296
+                    unset($data3);
297
+
298
+                    if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
299
+                    $px3->SetPrecisionY(0);
300
+                    $px3->SetLegend($legend);
301
+                    $px3->setShowLegend(0);
302
+                    $px3->setShowPointValue($showpointvalue);
303
+                    $px3->setShowPercent(0);
304
+                    $px3->SetMaxValue($px3->GetCeilMaxValue());
305
+                    $px3->SetWidth($WIDTH);
306
+                    $px3->SetHeight($HEIGHT);
307
+                    //$px3->SetYLabel($langs->trans("AmountOfBillsHT"));
308
+                    $px3->SetShading(3);
309
+                    $px3->SetHorizTickIncrement(1);
310
+                    $px3->SetPrecisionY(0);
311
+                    $px3->SetCssPrefix("cssboxes");
312
+                    //$px3->mode='depth';
313
+                    $px3->SetType(array('pie'));
314
+                    $px3->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Orders")));
315
+                    $px3->combine = 0.05;
316
+
317
+                    $px3->draw($filenamenb,$fileurlnb);
318
+                }
319
+            }
320
+        }
321
+
322
+        if (empty($nbofgraph))
323
+        {
324
+            $langs->load("errors");
325
+            $mesg=$langs->trans("ReadPermissionNotAllowed");
326
+        }
327
+        if (empty($conf->use_javascript_ajax))
328
+        {
329
+            $langs->load("errors");
330
+            $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
331
+        }
332
+
333
+        if (! $mesg)
334
+        {
335
+            $stringtoshow='';
336
+            $stringtoshow.='<script type="text/javascript" language="javascript">
337 337
 				jQuery(document).ready(function() {
338 338
 					jQuery("#idsubimg'.$this->boxcode.'").click(function() {
339 339
 						jQuery("#idfilter'.$this->boxcode.'").toggle();
340 340
 					});
341 341
 				});
342 342
 			</script>';
343
-			$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
344
-			$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
345
-			$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
346
-			$stringtoshow.='<input type="hidden" name="page_y" value="">';
347
-			$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
348
-			if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
349
-			{
350
-				$stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices");
351
-				$stringtoshow.=' &nbsp; ';
352
-			}
353
-			if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
354
-			{
355
-				$stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals");
356
-				$stringtoshow.='&nbsp;';
357
-			}
358
-			if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
359
-			{
360
-				$stringtoshow.='<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb?' checked':'').'> '.$langs->trans("ForCustomersOrders");
361
-			}
362
-			$stringtoshow.='<br>';
363
-			$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
364
-			$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('','refresh.png','','',1).'">';
365
-			$stringtoshow.='</form>';
366
-			$stringtoshow.='</div>';
367
-
368
-			if ($nbofgraph == 1)
369
-			{
370
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
371
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
372
-				else $stringtoshow.=$px3->show();
373
-			}
374
-			if ($nbofgraph == 2)
375
-			{
376
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
377
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
378
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
379
-				$stringtoshow.='</div><div class="fichehalfright">';
380
-				if ($showordernb) $stringtoshow.=$px3->show();
381
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
382
-				$stringtoshow.='</div></div></div>';
383
-			}
384
-			if ($nbofgraph == 3)
385
-			{
386
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
387
-				$stringtoshow.=$px1->show();
388
-				$stringtoshow.='</div><div class="fichehalfright">';
389
-				$stringtoshow.=$px2->show();
390
-				$stringtoshow.='</div></div></div>';
391
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter">';
392
-				$stringtoshow.=$px3->show();
393
-				$stringtoshow.='</div></div>';
394
-			}
395
-			$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
396
-		}
397
-		else
398
-		{
399
-			$this->info_box_contents[0][0] = array(
400
-			    'td' => 'align="left" class="nohover opacitymedium"',
401
-				'maxlength'=>500,
402
-				'text' => $mesg
403
-			);
404
-		}
405
-	}
406
-
407
-	/**
408
-	 *	Method to show box
409
-	 *
410
-	 *	@param	array	$head       Array with properties of box title
411
-	 *	@param  array	$contents   Array with properties of box lines
412
-	 *  @param	int		$nooutput	No print, only return string
413
-	 *	@return	string
414
-	 */
343
+            $stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
344
+            $stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
345
+            $stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
346
+            $stringtoshow.='<input type="hidden" name="page_y" value="">';
347
+            $stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
348
+            if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
349
+            {
350
+                $stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices");
351
+                $stringtoshow.=' &nbsp; ';
352
+            }
353
+            if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
354
+            {
355
+                $stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals");
356
+                $stringtoshow.='&nbsp;';
357
+            }
358
+            if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
359
+            {
360
+                $stringtoshow.='<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb?' checked':'').'> '.$langs->trans("ForCustomersOrders");
361
+            }
362
+            $stringtoshow.='<br>';
363
+            $stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
364
+            $stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('','refresh.png','','',1).'">';
365
+            $stringtoshow.='</form>';
366
+            $stringtoshow.='</div>';
367
+
368
+            if ($nbofgraph == 1)
369
+            {
370
+                if ($showinvoicenb) $stringtoshow.=$px1->show();
371
+                else if ($showpropalnb) $stringtoshow.=$px2->show();
372
+                else $stringtoshow.=$px3->show();
373
+            }
374
+            if ($nbofgraph == 2)
375
+            {
376
+                $stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
377
+                if ($showinvoicenb) $stringtoshow.=$px1->show();
378
+                else if ($showpropalnb) $stringtoshow.=$px2->show();
379
+                $stringtoshow.='</div><div class="fichehalfright">';
380
+                if ($showordernb) $stringtoshow.=$px3->show();
381
+                else if ($showpropalnb) $stringtoshow.=$px2->show();
382
+                $stringtoshow.='</div></div></div>';
383
+            }
384
+            if ($nbofgraph == 3)
385
+            {
386
+                $stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
387
+                $stringtoshow.=$px1->show();
388
+                $stringtoshow.='</div><div class="fichehalfright">';
389
+                $stringtoshow.=$px2->show();
390
+                $stringtoshow.='</div></div></div>';
391
+                $stringtoshow.='<div class="fichecenter"><div class="containercenter">';
392
+                $stringtoshow.=$px3->show();
393
+                $stringtoshow.='</div></div>';
394
+            }
395
+            $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
396
+        }
397
+        else
398
+        {
399
+            $this->info_box_contents[0][0] = array(
400
+                'td' => 'align="left" class="nohover opacitymedium"',
401
+                'maxlength'=>500,
402
+                'text' => $mesg
403
+            );
404
+        }
405
+    }
406
+
407
+    /**
408
+     *	Method to show box
409
+     *
410
+     *	@param	array	$head       Array with properties of box title
411
+     *	@param  array	$contents   Array with properties of box lines
412
+     *  @param	int		$nooutput	No print, only return string
413
+     *	@return	string
414
+     */
415 415
     function showBox($head = null, $contents = null, $nooutput=0)
416 416
     {
417
-		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
418
-	}
417
+        return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
418
+    }
419 419
 }
420 420
 
Please login to merge, or discard this patch.
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class box_graph_product_distribution extends ModeleBoxes
31 31
 {
32
-	var $boxcode="productdistribution";
33
-	var $boximg="object_product";
34
-	var $boxlabel="BoxProductDistribution";
35
-	var $depends = array("product|service","facture|propal|commande");
32
+	var $boxcode = "productdistribution";
33
+	var $boximg = "object_product";
34
+	var $boxlabel = "BoxProductDistribution";
35
+	var $depends = array("product|service", "facture|propal|commande");
36 36
 
37 37
 	/**
38 38
      * @var DoliDB Database handler.
@@ -51,16 +51,16 @@  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, $conf;
57 57
 
58
-		$this->db=$db;
58
+		$this->db = $db;
59 59
 
60
-		$this->hidden = ! (
61
-		    (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
62
-		 || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
63
-		 || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
60
+		$this->hidden = !(
61
+		    (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
62
+		 || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
63
+		 || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
64 64
 		);
65 65
 	}
66 66
 
@@ -70,52 +70,52 @@  discard block
 block discarded – undo
70 70
 	 *  @param	int		$max        Maximum number of records to load
71 71
      *  @return	void
72 72
 	 */
73
-	function loadBox($max=5)
73
+	function loadBox($max = 5)
74 74
 	{
75 75
 		global $conf, $user, $langs, $db;
76 76
 
77
-		$this->max=$max;
77
+		$this->max = $max;
78 78
 
79
-		$refreshaction='refresh_'.$this->boxcode;
79
+		$refreshaction = 'refresh_'.$this->boxcode;
80 80
 
81 81
 		include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
82 82
 		include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
83 83
 		include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
84 84
 
85
-		$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
86
-		$param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
87
-		$param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
88
-		$param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
89
-		$autosetarray=preg_split("/[,;:]+/",GETPOST('DOL_AUTOSET_COOKIE'));
90
-		if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
85
+		$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
86
+		$param_showinvoicenb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
87
+		$param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
88
+		$param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
89
+		$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
90
+		if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
91 91
 		{
92
-			$year=GETPOST($param_year,'int');
93
-			$showinvoicenb=GETPOST($param_showinvoicenb,'alpha');
94
-			$showpropalnb=GETPOST($param_showpropalnb,'alpha');
95
-			$showordernb=GETPOST($param_showordernb,'alpha');
92
+			$year = GETPOST($param_year, 'int');
93
+			$showinvoicenb = GETPOST($param_showinvoicenb, 'alpha');
94
+			$showpropalnb = GETPOST($param_showpropalnb, 'alpha');
95
+			$showordernb = GETPOST($param_showordernb, 'alpha');
96 96
 		}
97 97
 		else
98 98
 		{
99
-			$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
100
-			$year=$tmparray['year'];
101
-			$showinvoicenb=$tmparray['showinvoicenb'];
102
-			$showpropalnb=$tmparray['showpropalnb'];
103
-			$showordernb=$tmparray['showordernb'];
99
+			$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
100
+			$year = $tmparray['year'];
101
+			$showinvoicenb = $tmparray['showinvoicenb'];
102
+			$showpropalnb = $tmparray['showpropalnb'];
103
+			$showordernb = $tmparray['showordernb'];
104 104
 		}
105
-		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
106
-		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
107
-		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
108
-		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
105
+		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; }
106
+		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb = 0;
107
+		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb = 0;
108
+		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb = 0;
109 109
 
110
-		$nowarray=dol_getdate(dol_now(),true);
111
-		if (empty($year)) $year=$nowarray['year'];
110
+		$nowarray = dol_getdate(dol_now(), true);
111
+		if (empty($year)) $year = $nowarray['year'];
112 112
 
113
-		$nbofgraph=0;
113
+		$nbofgraph = 0;
114 114
 		if ($showinvoicenb) $nbofgraph++;
115 115
 		if ($showpropalnb)  $nbofgraph++;
116 116
 		if ($showordernb)   $nbofgraph++;
117 117
 
118
-		$text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year;
118
+		$text = $langs->trans("BoxProductDistribution", $max).' - '.$langs->trans("Year").': '.$year;
119 119
 		$this->info_box_head = array(
120 120
 				'text' => $text,
121 121
 				'limit'=> dol_strlen($text),
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 		);
129 129
 
130 130
 
131
-		$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
132
-		if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
133
-		if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
131
+		$paramtitle = $langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
132
+		if (empty($conf->produit->enabled)) $paramtitle = $langs->transnoentitiesnoconv("Services");
133
+		if (empty($conf->service->enabled)) $paramtitle = $langs->transnoentitiesnoconv("Products");
134 134
 
135
-		$socid=empty($user->societe_id)?0:$user->societe_id;
136
-		$userid=0;	// No filter on user creation
135
+		$socid = empty($user->societe_id) ? 0 : $user->societe_id;
136
+		$userid = 0; // No filter on user creation
137 137
 
138
-		$WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
139
-		$HEIGHT='192';
138
+		$WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320';
139
+		$HEIGHT = '192';
140 140
 
141
-		if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
141
+		if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
142 142
 		{
143 143
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
144 144
 			if ($showinvoicenb)
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 				include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
148 148
 
149 149
 				$showpointvalue = 1; $nocolor = 0;
150
-				$mode='customer';
151
-				$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0));
152
-				$data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
150
+				$mode = 'customer';
151
+				$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
152
+				$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
153 153
 				if (empty($data1))
154 154
 				{
155
-					$showpointvalue=0;
156
-					$nocolor=1;
157
-					$data1=array(array(0=>$langs->trans("None"),1=>1));
155
+					$showpointvalue = 0;
156
+					$nocolor = 1;
157
+					$data1 = array(array(0=>$langs->trans("None"), 1=>1));
158 158
 				}
159 159
 				$filenamenb = $dir."/prodserforinvoice-".$year.".png";
160 160
 				$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&amp;file=prodserforinvoice-'.$year.'.png';
161 161
 
162 162
 				$px1 = new DolGraph();
163 163
 				$mesg = $px1->isGraphKo();
164
-				if (! $mesg)
164
+				if (!$mesg)
165 165
 				{
166
-					$i=0;$tot=count($data1);$legend=array();
166
+					$i = 0; $tot = count($data1); $legend = array();
167 167
 					while ($i <= $tot)
168 168
 					{
169
-						$data1[$i][0]=dol_trunc($data1[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
170
-						$legend[]=$data1[$i][0];
169
+						$data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
170
+						$legend[] = $data1[$i][0];
171 171
 						$i++;
172 172
 					}
173 173
 
174 174
 					$px1->SetData($data1);
175 175
 					unset($data1);
176 176
 
177
-					if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
177
+					if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220)));
178 178
 					$px1->SetPrecisionY(0);
179 179
 					$px1->SetLegend($legend);
180 180
 					$px1->setShowLegend(0);
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 					$px1->SetCssPrefix("cssboxes");
191 191
 					//$px1->mode='depth';
192 192
 					$px1->SetType(array('pie'));
193
-					$px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices")));
193
+					$px1->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Invoices")));
194 194
 					$px1->combine = 0.05;
195 195
 
196
-					$px1->draw($filenamenb,$fileurlnb);
196
+					$px1->draw($filenamenb, $fileurlnb);
197 197
 				}
198 198
 			}
199 199
 		}
200 200
 
201
-		if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
201
+		if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
202 202
 		{
203 203
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
204 204
 			if ($showpropalnb)
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 				include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
208 208
 
209 209
 				$showpointvalue = 1; $nocolor = 0;
210
-				$stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0));
211
-				$data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
210
+				$stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0));
211
+				$data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
212 212
 				if (empty($data2))
213 213
 				{
214 214
 					$showpointvalue = 0;
215 215
 					$nocolor = 1;
216
-					$data2=array(array(0=>$langs->trans("None"),1=>1));
216
+					$data2 = array(array(0=>$langs->trans("None"), 1=>1));
217 217
 				}
218 218
 
219 219
 				$filenamenb = $dir."/prodserforpropal-".$year.".png";
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
 
222 222
 				$px2 = new DolGraph();
223 223
 				$mesg = $px2->isGraphKo();
224
-				if (! $mesg)
224
+				if (!$mesg)
225 225
 				{
226
-					$i=0;$tot=count($data2);$legend=array();
226
+					$i = 0; $tot = count($data2); $legend = array();
227 227
 					while ($i <= $tot)
228 228
 					{
229
-						$data2[$i][0]=dol_trunc($data2[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
230
-						$legend[]=$data2[$i][0];
229
+						$data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
230
+						$legend[] = $data2[$i][0];
231 231
 						$i++;
232 232
 					}
233 233
 
234 234
 					$px2->SetData($data2);
235 235
 					unset($data2);
236 236
 
237
-					if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
237
+					if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220)));
238 238
 					$px2->SetPrecisionY(0);
239 239
 					$px2->SetLegend($legend);
240 240
 					$px2->setShowLegend(0);
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 					$px2->SetCssPrefix("cssboxes");
251 251
 					//$px2->mode='depth';
252 252
 					$px2->SetType(array('pie'));
253
-					$px2->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Proposals")));
253
+					$px2->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Proposals")));
254 254
 					$px2->combine = 0.05;
255 255
 
256
-					$px2->draw($filenamenb,$fileurlnb);
256
+					$px2->draw($filenamenb, $fileurlnb);
257 257
 				}
258 258
 			}
259 259
 		}
260 260
 
261
-		if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
261
+		if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
262 262
 		{
263 263
 			// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
264 264
 			if ($showordernb)
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 				include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
268 268
 
269 269
 				$showpointvalue = 1; $nocolor = 0;
270
-				$mode='customer';
271
-				$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0));
272
-				$data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action','aZ09')==$refreshaction?-1:(3600*24)));
270
+				$mode = 'customer';
271
+				$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
272
+				$data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
273 273
 				if (empty($data3))
274 274
 				{
275 275
 					$showpointvalue = 0;
276 276
 					$nocolor = 1;
277
-					$data3=array(array(0=>$langs->trans("None"),1=>1));
277
+					$data3 = array(array(0=>$langs->trans("None"), 1=>1));
278 278
 				}
279 279
 
280 280
 				$filenamenb = $dir."/prodserfororder-".$year.".png";
@@ -282,20 +282,20 @@  discard block
 block discarded – undo
282 282
 
283 283
 				$px3 = new DolGraph();
284 284
 				$mesg = $px3->isGraphKo();
285
-				if (! $mesg)
285
+				if (!$mesg)
286 286
 				{
287
-					$i=0;$tot=count($data3);$legend=array();
287
+					$i = 0; $tot = count($data3); $legend = array();
288 288
 					while ($i <= $tot)
289 289
 					{
290
-						$data3[$i][0]=dol_trunc($data3[$i][0],5);	// Required to avoid error "Could not draw pie with labels contained inside canvas"
291
-						$legend[]=$data3[$i][0];
290
+						$data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
291
+						$legend[] = $data3[$i][0];
292 292
 						$i++;
293 293
 					}
294 294
 
295 295
 					$px3->SetData($data3);
296 296
 					unset($data3);
297 297
 
298
-					if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
298
+					if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220)));
299 299
 					$px3->SetPrecisionY(0);
300 300
 					$px3->SetLegend($legend);
301 301
 					$px3->setShowLegend(0);
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 					$px3->SetCssPrefix("cssboxes");
312 312
 					//$px3->mode='depth';
313 313
 					$px3->SetType(array('pie'));
314
-					$px3->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Orders")));
314
+					$px3->SetTitle($langs->trans("BoxProductDistributionFor", $paramtitle, $langs->transnoentitiesnoconv("Orders")));
315 315
 					$px3->combine = 0.05;
316 316
 
317
-					$px3->draw($filenamenb,$fileurlnb);
317
+					$px3->draw($filenamenb, $fileurlnb);
318 318
 				}
319 319
 			}
320 320
 		}
@@ -322,77 +322,77 @@  discard block
 block discarded – undo
322 322
 		if (empty($nbofgraph))
323 323
 		{
324 324
 		    $langs->load("errors");
325
-		    $mesg=$langs->trans("ReadPermissionNotAllowed");
325
+		    $mesg = $langs->trans("ReadPermissionNotAllowed");
326 326
 		}
327 327
 		if (empty($conf->use_javascript_ajax))
328 328
 		{
329 329
 			$langs->load("errors");
330
-			$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
330
+			$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
331 331
 		}
332 332
 
333
-		if (! $mesg)
333
+		if (!$mesg)
334 334
 		{
335
-			$stringtoshow='';
336
-			$stringtoshow.='<script type="text/javascript" language="javascript">
335
+			$stringtoshow = '';
336
+			$stringtoshow .= '<script type="text/javascript" language="javascript">
337 337
 				jQuery(document).ready(function() {
338 338
 					jQuery("#idsubimg'.$this->boxcode.'").click(function() {
339 339
 						jQuery("#idfilter'.$this->boxcode.'").toggle();
340 340
 					});
341 341
 				});
342 342
 			</script>';
343
-			$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">';	// hideobject is to start hidden
344
-			$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
345
-			$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
346
-			$stringtoshow.='<input type="hidden" name="page_y" value="">';
347
-			$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
348
-			if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
343
+			$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
344
+			$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
345
+			$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
346
+			$stringtoshow .= '<input type="hidden" name="page_y" value="">';
347
+			$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
348
+			if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire))
349 349
 			{
350
-				$stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices");
351
-				$stringtoshow.=' &nbsp; ';
350
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb ? ' checked' : '').'> '.$langs->trans("ForCustomersInvoices");
351
+				$stringtoshow .= ' &nbsp; ';
352 352
 			}
353
-			if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
353
+			if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire))
354 354
 			{
355
-				$stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals");
356
-				$stringtoshow.='&nbsp;';
355
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb ? ' checked' : '').'> '.$langs->trans("ForProposals");
356
+				$stringtoshow .= '&nbsp;';
357 357
 			}
358
-			if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
358
+			if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire))
359 359
 			{
360
-				$stringtoshow.='<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb?' checked':'').'> '.$langs->trans("ForCustomersOrders");
360
+				$stringtoshow .= '<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb ? ' checked' : '').'> '.$langs->trans("ForCustomersOrders");
361 361
 			}
362
-			$stringtoshow.='<br>';
363
-			$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
364
-			$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('','refresh.png','','',1).'">';
365
-			$stringtoshow.='</form>';
366
-			$stringtoshow.='</div>';
362
+			$stringtoshow .= '<br>';
363
+			$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
364
+			$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('', 'refresh.png', '', '', 1).'">';
365
+			$stringtoshow .= '</form>';
366
+			$stringtoshow .= '</div>';
367 367
 
368 368
 			if ($nbofgraph == 1)
369 369
 			{
370
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
371
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
372
-				else $stringtoshow.=$px3->show();
370
+				if ($showinvoicenb) $stringtoshow .= $px1->show();
371
+				else if ($showpropalnb) $stringtoshow .= $px2->show();
372
+				else $stringtoshow .= $px3->show();
373 373
 			}
374 374
 			if ($nbofgraph == 2)
375 375
 			{
376
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
377
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
378
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
379
-				$stringtoshow.='</div><div class="fichehalfright">';
380
-				if ($showordernb) $stringtoshow.=$px3->show();
381
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
382
-				$stringtoshow.='</div></div></div>';
376
+				$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
377
+				if ($showinvoicenb) $stringtoshow .= $px1->show();
378
+				else if ($showpropalnb) $stringtoshow .= $px2->show();
379
+				$stringtoshow .= '</div><div class="fichehalfright">';
380
+				if ($showordernb) $stringtoshow .= $px3->show();
381
+				else if ($showpropalnb) $stringtoshow .= $px2->show();
382
+				$stringtoshow .= '</div></div></div>';
383 383
 			}
384 384
 			if ($nbofgraph == 3)
385 385
 			{
386
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
387
-				$stringtoshow.=$px1->show();
388
-				$stringtoshow.='</div><div class="fichehalfright">';
389
-				$stringtoshow.=$px2->show();
390
-				$stringtoshow.='</div></div></div>';
391
-				$stringtoshow.='<div class="fichecenter"><div class="containercenter">';
392
-				$stringtoshow.=$px3->show();
393
-				$stringtoshow.='</div></div>';
386
+				$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
387
+				$stringtoshow .= $px1->show();
388
+				$stringtoshow .= '</div><div class="fichehalfright">';
389
+				$stringtoshow .= $px2->show();
390
+				$stringtoshow .= '</div></div></div>';
391
+				$stringtoshow .= '<div class="fichecenter"><div class="containercenter">';
392
+				$stringtoshow .= $px3->show();
393
+				$stringtoshow .= '</div></div>';
394 394
 			}
395
-			$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
395
+			$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"', 'textnoformat'=>$stringtoshow);
396 396
 		}
397 397
 		else
398 398
 		{
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 *  @param	int		$nooutput	No print, only return string
413 413
 	 *	@return	string
414 414
 	 */
415
-    function showBox($head = null, $contents = null, $nooutput=0)
415
+    function showBox($head = null, $contents = null, $nooutput = 0)
416 416
     {
417 417
 		return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
418 418
 	}
Please login to merge, or discard this patch.
Braces   +55 added lines, -23 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
 			$showinvoicenb=GETPOST($param_showinvoicenb,'alpha');
94 94
 			$showpropalnb=GETPOST($param_showpropalnb,'alpha');
95 95
 			$showordernb=GETPOST($param_showordernb,'alpha');
96
-		}
97
-		else
96
+		} else
98 97
 		{
99 98
 			$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
100 99
 			$year=$tmparray['year'];
@@ -103,17 +102,31 @@  discard block
 block discarded – undo
103 102
 			$showordernb=$tmparray['showordernb'];
104 103
 		}
105 104
 		if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
106
-		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
107
-		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
108
-		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
105
+		if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) {
106
+		    $showinvoicenb=0;
107
+		}
108
+		if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) {
109
+		    $showpropalnb=0;
110
+		}
111
+		if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) {
112
+		    $showordernb=0;
113
+		}
109 114
 
110 115
 		$nowarray=dol_getdate(dol_now(),true);
111
-		if (empty($year)) $year=$nowarray['year'];
116
+		if (empty($year)) {
117
+		    $year=$nowarray['year'];
118
+		}
112 119
 
113 120
 		$nbofgraph=0;
114
-		if ($showinvoicenb) $nbofgraph++;
115
-		if ($showpropalnb)  $nbofgraph++;
116
-		if ($showordernb)   $nbofgraph++;
121
+		if ($showinvoicenb) {
122
+		    $nbofgraph++;
123
+		}
124
+		if ($showpropalnb) {
125
+		    $nbofgraph++;
126
+		}
127
+		if ($showordernb) {
128
+		    $nbofgraph++;
129
+		}
117 130
 
118 131
 		$text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year;
119 132
 		$this->info_box_head = array(
@@ -129,8 +142,12 @@  discard block
 block discarded – undo
129 142
 
130 143
 
131 144
 		$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
132
-		if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
133
-		if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
145
+		if (empty($conf->produit->enabled)) {
146
+		    $paramtitle=$langs->transnoentitiesnoconv("Services");
147
+		}
148
+		if (empty($conf->service->enabled)) {
149
+		    $paramtitle=$langs->transnoentitiesnoconv("Products");
150
+		}
134 151
 
135 152
 		$socid=empty($user->societe_id)?0:$user->societe_id;
136 153
 		$userid=0;	// No filter on user creation
@@ -174,7 +191,9 @@  discard block
 block discarded – undo
174 191
 					$px1->SetData($data1);
175 192
 					unset($data1);
176 193
 
177
-					if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
194
+					if ($nocolor) {
195
+					    $px1->SetDataColor(array(array(220,220,220)));
196
+					}
178 197
 					$px1->SetPrecisionY(0);
179 198
 					$px1->SetLegend($legend);
180 199
 					$px1->setShowLegend(0);
@@ -234,7 +253,9 @@  discard block
 block discarded – undo
234 253
 					$px2->SetData($data2);
235 254
 					unset($data2);
236 255
 
237
-					if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
256
+					if ($nocolor) {
257
+					    $px2->SetDataColor(array(array(220,220,220)));
258
+					}
238 259
 					$px2->SetPrecisionY(0);
239 260
 					$px2->SetLegend($legend);
240 261
 					$px2->setShowLegend(0);
@@ -295,7 +316,9 @@  discard block
 block discarded – undo
295 316
 					$px3->SetData($data3);
296 317
 					unset($data3);
297 318
 
298
-					if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
319
+					if ($nocolor) {
320
+					    $px3->SetDataColor(array(array(220,220,220)));
321
+					}
299 322
 					$px3->SetPrecisionY(0);
300 323
 					$px3->SetLegend($legend);
301 324
 					$px3->setShowLegend(0);
@@ -367,18 +390,28 @@  discard block
 block discarded – undo
367 390
 
368 391
 			if ($nbofgraph == 1)
369 392
 			{
370
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
371
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
372
-				else $stringtoshow.=$px3->show();
393
+				if ($showinvoicenb) {
394
+				    $stringtoshow.=$px1->show();
395
+				} else if ($showpropalnb) {
396
+				    $stringtoshow.=$px2->show();
397
+				} else {
398
+				    $stringtoshow.=$px3->show();
399
+				}
373 400
 			}
374 401
 			if ($nbofgraph == 2)
375 402
 			{
376 403
 				$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
377
-				if ($showinvoicenb) $stringtoshow.=$px1->show();
378
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
404
+				if ($showinvoicenb) {
405
+				    $stringtoshow.=$px1->show();
406
+				} else if ($showpropalnb) {
407
+				    $stringtoshow.=$px2->show();
408
+				}
379 409
 				$stringtoshow.='</div><div class="fichehalfright">';
380
-				if ($showordernb) $stringtoshow.=$px3->show();
381
-				else if ($showpropalnb) $stringtoshow.=$px2->show();
410
+				if ($showordernb) {
411
+				    $stringtoshow.=$px3->show();
412
+				} else if ($showpropalnb) {
413
+				    $stringtoshow.=$px2->show();
414
+				}
382 415
 				$stringtoshow.='</div></div></div>';
383 416
 			}
384 417
 			if ($nbofgraph == 3)
@@ -393,8 +426,7 @@  discard block
 block discarded – undo
393 426
 				$stringtoshow.='</div></div>';
394 427
 			}
395 428
 			$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow);
396
-		}
397
-		else
429
+		} else
398 430
 		{
399 431
 			$this->info_box_contents[0][0] = array(
400 432
 			    'td' => 'align="left" class="nohover opacitymedium"',
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_supplier_orders.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
                 while ($line < $num) {
112 112
                     $objp = $db->fetch_object($result);
113 113
                     $date=$db->jdate($objp->date_commande);
114
-					$datem=$db->jdate($objp->tms);
114
+                    $datem=$db->jdate($objp->tms);
115 115
 
116
-					$supplierorderstatic->id = $objp->rowid;
117
-					$supplierorderstatic->ref = $objp->ref;
116
+                    $supplierorderstatic->id = $objp->rowid;
117
+                    $supplierorderstatic->ref = $objp->ref;
118 118
 
119
-					$thirdpartytmp->id = $objp->socid;
119
+                    $thirdpartytmp->id = $objp->socid;
120 120
                     $thirdpartytmp->name = $objp->name;
121 121
                     $thirdpartytmp->fournisseur = 1;
122 122
                     $thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                     $this->info_box_contents[$line][] = array(
126 126
                         'td' => '',
127 127
                         'text' => $supplierorderstatic->getNomUrl(1),
128
-                    	'asis' => 1
128
+                        'asis' => 1
129 129
                     );
130 130
 
131 131
                     $this->info_box_contents[$line][] = array(
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                         'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
140 140
                     );
141 141
 
142
-					$this->info_box_contents[$line][] = array(
142
+                    $this->info_box_contents[$line][] = array(
143 143
                         'td' => 'class="right"',
144 144
                         'text' => dol_print_date($date,'day'),
145 145
                     );
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * 	@param	array	$head       Array with properties of box title
183 183
      * 	@param  array	$contents   Array with properties of box lines
184
-	 *  @param	int		$nooutput	No print, only return string
185
-	 *	@return	string
186
-	 */
184
+     *  @param	int		$nooutput	No print, only return string
185
+     *	@return	string
186
+     */
187 187
     function showBox($head = null, $contents = null, $nooutput=0)
188 188
     {
189 189
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
     var $boxcode = "latestsupplierorders";
35 35
     var $boximg = "object_order";
36
-    var $boxlabel="BoxLatestSupplierOrders";
36
+    var $boxlabel = "BoxLatestSupplierOrders";
37 37
     var $depends = array("fournisseur");
38 38
 
39 39
     /**
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
      *  @param  DoliDB  $db         Database handler
53 53
      *  @param  string  $param      More parameters
54 54
      */
55
-    function __construct($db,$param)
55
+    function __construct($db, $param)
56 56
     {
57 57
         global $user;
58 58
 
59
-        $this->db=$db;
59
+        $this->db = $db;
60 60
 
61
-        $this->hidden=! ($user->rights->fournisseur->commande->lire);
61
+        $this->hidden = !($user->rights->fournisseur->commande->lire);
62 62
     }
63 63
 
64 64
     /**
@@ -75,32 +75,32 @@  discard block
 block discarded – undo
75 75
         $this->max = $max;
76 76
 
77 77
         include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
78
-        $supplierorderstatic=new CommandeFournisseur($db);
78
+        $supplierorderstatic = new CommandeFournisseur($db);
79 79
         include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
80 80
         $thirdpartytmp = new Fournisseur($db);
81 81
 
82
-        $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max));
82
+        $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max));
83 83
 
84 84
         if ($user->rights->fournisseur->commande->lire)
85 85
         {
86 86
             $sql = "SELECT s.nom as name, s.rowid as socid,";
87
-            $sql.= " s.code_client, s.code_fournisseur,";
88
-            $sql.= " s.logo,";
89
-            $sql.= " c.rowid, c.ref, c.tms, c.date_commande,";
90
-            $sql.= " c.total_ht,";
91
-            $sql.= " c.tva as total_tva,";
92
-            $sql.= " c.total_ttc,";
93
-            $sql.= " c.fk_statut";
94
-            $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
95
-            $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
96
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
97
-            $sql.= " WHERE c.fk_soc = s.rowid";
98
-            $sql.= " AND c.entity = ".$conf->entity;
99
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
100
-            if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
101
-            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC ";
102
-            else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
103
-            $sql.= $db->plimit($max, 0);
87
+            $sql .= " s.code_client, s.code_fournisseur,";
88
+            $sql .= " s.logo,";
89
+            $sql .= " c.rowid, c.ref, c.tms, c.date_commande,";
90
+            $sql .= " c.total_ht,";
91
+            $sql .= " c.tva as total_tva,";
92
+            $sql .= " c.total_ttc,";
93
+            $sql .= " c.fk_statut";
94
+            $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
95
+            $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
96
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
97
+            $sql .= " WHERE c.fk_soc = s.rowid";
98
+            $sql .= " AND c.entity = ".$conf->entity;
99
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
100
+            if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
101
+            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
102
+            else $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
103
+            $sql .= $db->plimit($max, 0);
104 104
 
105 105
             $result = $db->query($sql);
106 106
             if ($result)
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
                 $line = 0;
111 111
                 while ($line < $num) {
112 112
                     $objp = $db->fetch_object($result);
113
-                    $date=$db->jdate($objp->date_commande);
114
-					$datem=$db->jdate($objp->tms);
113
+                    $date = $db->jdate($objp->date_commande);
114
+					$datem = $db->jdate($objp->tms);
115 115
 
116 116
 					$supplierorderstatic->id = $objp->rowid;
117 117
 					$supplierorderstatic->ref = $objp->ref;
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 
142 142
 					$this->info_box_contents[$line][] = array(
143 143
                         'td' => 'class="right"',
144
-                        'text' => dol_print_date($date,'day'),
144
+                        'text' => dol_print_date($date, 'day'),
145 145
                     );
146 146
 
147 147
                     $this->info_box_contents[$line][] = array(
148 148
                         'td' => 'align="right" width="18"',
149
-                        'text' => $supplierorderstatic->LibStatut($objp->fk_statut,3),
149
+                        'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3),
150 150
                     );
151 151
 
152 152
                     $line++;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 *  @param	int		$nooutput	No print, only return string
185 185
 	 *	@return	string
186 186
 	 */
187
-    function showBox($head = null, $contents = null, $nooutput=0)
187
+    function showBox($head = null, $contents = null, $nooutput = 0)
188 188
     {
189 189
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
190 190
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -93,13 +93,22 @@  discard block
 block discarded – undo
93 93
             $sql.= " c.fk_statut";
94 94
             $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
95 95
             $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
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.= " WHERE c.fk_soc = s.rowid";
98 100
             $sql.= " AND c.entity = ".$conf->entity;
99
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
100
-            if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
101
-            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC ";
102
-            else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
101
+            if (!$user->rights->societe->client->voir && !$user->societe_id) {
102
+                $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
103
+            }
104
+            if ($user->societe_id) {
105
+                $sql.= " AND s.rowid = ".$user->societe_id;
106
+            }
107
+            if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
108
+                $sql.= " ORDER BY c.date_commande DESC, c.ref DESC ";
109
+            } else {
110
+                $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
111
+            }
103 112
             $sql.= $db->plimit($max, 0);
104 113
 
105 114
             $result = $db->query($sql);
@@ -152,11 +161,12 @@  discard block
 block discarded – undo
152 161
                     $line++;
153 162
                 }
154 163
 
155
-                if ($num == 0)
156
-                    $this->info_box_contents[$line][] = array(
164
+                if ($num == 0) {
165
+                                    $this->info_box_contents[$line][] = array(
157 166
                         'td' => 'align="center"',
158 167
                         'text' => $langs->trans("NoSupplierOrder"),
159 168
                     );
169
+                }
160 170
 
161 171
                 $db->free($result);
162 172
             } else {
@@ -166,8 +176,7 @@  discard block
 block discarded – undo
166 176
                     'text' => ($db->error().' sql='.$sql),
167 177
                 );
168 178
             }
169
-        }
170
-        else
179
+        } else
171 180
         {
172 181
             $this->info_box_contents[0][] = array(
173 182
                 'td' => 'align="left" class="nohover opacitymedium"',
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_fournisseurs.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
     var $boxlabel="BoxLastSuppliers";
37 37
     var $depends = array("fournisseur");
38 38
 
39
-	/**
39
+    /**
40 40
      * @var DoliDB Database handler.
41 41
      */
42 42
     public $db;
43 43
     
44
-	var $param;
44
+    var $param;
45 45
 
46 46
     var $info_box_head = array();
47 47
     var $info_box_contents = array();
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     /**
66
-	 *  Load data into info_box_contents array to show array later.
67
-	 *
68
-	 *  @param	int		$max        Maximum number of records to load
66
+     *  Load data into info_box_contents array to show array later.
67
+     *
68
+     *  @param	int		$max        Maximum number of records to load
69 69
      *  @return	void
70 70
      */
71 71
     function loadBox($max=5)
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
         global $conf, $user, $langs, $db;
74 74
         $langs->load("boxes");
75 75
 
76
-		$this->max=$max;
76
+        $this->max=$max;
77 77
 
78 78
         include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
79 79
         $thirdpartystatic=new Societe($db);
80
-		include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
81
-		$thirdpartytmp=new Fournisseur($db);
80
+        include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
81
+        $thirdpartytmp=new Fournisseur($db);
82 82
 
83
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers",$max));
83
+        $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers",$max));
84 84
 
85 85
         if ($user->rights->societe->lire)
86 86
         {
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
                 while ($line < $num)
106 106
                 {
107 107
                     $objp = $db->fetch_object($result);
108
-    				$datec=$db->jdate($objp->datec);
109
-    				$datem=$db->jdate($objp->tms);
110
-					$thirdpartytmp->id = $objp->socid;
108
+                    $datec=$db->jdate($objp->datec);
109
+                    $datem=$db->jdate($objp->tms);
110
+                    $thirdpartytmp->id = $objp->socid;
111 111
                     $thirdpartytmp->name = $objp->name;
112 112
                     $thirdpartytmp->code_client = $objp->code_client;
113 113
                     $thirdpartytmp->logo = $objp->logo;
114 114
 
115
-                   	$this->info_box_contents[$line][] = array(
115
+                        $this->info_box_contents[$line][] = array(
116 116
                         'td' => '',
117 117
                         'text' => $thirdpartytmp->getNomUrl(1, '', 40),
118 118
                         'asis' => 1,
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
         }
153 153
     }
154 154
 
155
-	/**
156
-	 *	Method to show box
157
-	 *
158
-	 *	@param	array	$head       Array with properties of box title
159
-	 *	@param  array	$contents   Array with properties of box lines
160
-	 *  @param	int		$nooutput	No print, only return string
161
-	 *	@return	string
162
-	 */
155
+    /**
156
+     *	Method to show box
157
+     *
158
+     *	@param	array	$head       Array with properties of box title
159
+     *	@param  array	$contents   Array with properties of box lines
160
+     *  @param	int		$nooutput	No print, only return string
161
+     *	@return	string
162
+     */
163 163
     function showBox($head = null, $contents = null, $nooutput=0)
164 164
     {
165 165
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class box_fournisseurs extends ModeleBoxes
33 33
 {
34
-    var $boxcode="lastsuppliers";
35
-    var $boximg="object_company";
36
-    var $boxlabel="BoxLastSuppliers";
34
+    var $boxcode = "lastsuppliers";
35
+    var $boximg = "object_company";
36
+    var $boxlabel = "BoxLastSuppliers";
37 37
     var $depends = array("fournisseur");
38 38
 
39 39
 	/**
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
      *  @param  DoliDB  $db         Database handler
54 54
      *  @param  string  $param      More parameters
55 55
      */
56
-    function __construct($db,$param)
56
+    function __construct($db, $param)
57 57
     {
58 58
         global $user;
59 59
 
60
-        $this->db=$db;
60
+        $this->db = $db;
61 61
 
62
-        $this->hidden=! ($user->rights->societe->lire && empty($user->socid));
62
+        $this->hidden = !($user->rights->societe->lire && empty($user->socid));
63 63
     }
64 64
 
65 65
     /**
@@ -68,33 +68,33 @@  discard block
 block discarded – undo
68 68
 	 *  @param	int		$max        Maximum number of records to load
69 69
      *  @return	void
70 70
      */
71
-    function loadBox($max=5)
71
+    function loadBox($max = 5)
72 72
     {
73 73
         global $conf, $user, $langs, $db;
74 74
         $langs->load("boxes");
75 75
 
76
-		$this->max=$max;
76
+		$this->max = $max;
77 77
 
78 78
         include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
79
-        $thirdpartystatic=new Societe($db);
79
+        $thirdpartystatic = new Societe($db);
80 80
 		include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
81
-		$thirdpartytmp=new Fournisseur($db);
81
+		$thirdpartytmp = new Fournisseur($db);
82 82
 
83
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers",$max));
83
+		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max));
84 84
 
85 85
         if ($user->rights->societe->lire)
86 86
         {
87 87
             $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,";
88
-            $sql.= " s.code_fournisseur,";
89
-            $sql.= " s.logo";
88
+            $sql .= " s.code_fournisseur,";
89
+            $sql .= " s.logo";
90 90
             $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
91
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
92
-            $sql.= " WHERE s.fournisseur = 1";
93
-            $sql.= " AND s.entity IN (".getEntity('societe').")";
94
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
-            if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
96
-            $sql.= " ORDER BY s.tms DESC ";
97
-            $sql.= $db->plimit($max, 0);
91
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
92
+            $sql .= " WHERE s.fournisseur = 1";
93
+            $sql .= " AND s.entity IN (".getEntity('societe').")";
94
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
95
+            if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id;
96
+            $sql .= " ORDER BY s.tms DESC ";
97
+            $sql .= $db->plimit($max, 0);
98 98
 
99 99
             $result = $db->query($sql);
100 100
             if ($result)
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
                 while ($line < $num)
106 106
                 {
107 107
                     $objp = $db->fetch_object($result);
108
-    				$datec=$db->jdate($objp->datec);
109
-    				$datem=$db->jdate($objp->tms);
108
+    				$datec = $db->jdate($objp->datec);
109
+    				$datem = $db->jdate($objp->tms);
110 110
 					$thirdpartytmp->id = $objp->socid;
111 111
                     $thirdpartytmp->name = $objp->name;
112 112
                     $thirdpartytmp->code_client = $objp->code_client;
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 
126 126
                     $this->info_box_contents[$line][] = array(
127 127
                         'td' => 'align="right" width="18"',
128
-                        'text' => $thirdpartystatic->LibStatut($objp->status,3),
128
+                        'text' => $thirdpartystatic->LibStatut($objp->status, 3),
129 129
                     );
130 130
 
131 131
                     $line++;
132 132
                 }
133 133
 
134
-                if ($num==0) $this->info_box_contents[$line][0] = array(
134
+                if ($num == 0) $this->info_box_contents[$line][0] = array(
135 135
                     'td' => 'align="center"',
136 136
                     'text'=>$langs->trans("NoRecordedSuppliers"),
137 137
                 );
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 *  @param	int		$nooutput	No print, only return string
161 161
 	 *	@return	string
162 162
 	 */
163
-    function showBox($head = null, $contents = null, $nooutput=0)
163
+    function showBox($head = null, $contents = null, $nooutput = 0)
164 164
     {
165 165
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
166 166
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,11 +88,17 @@  discard block
 block discarded – undo
88 88
             $sql.= " s.code_fournisseur,";
89 89
             $sql.= " s.logo";
90 90
             $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
91
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
91
+            if (!$user->rights->societe->client->voir && !$user->societe_id) {
92
+                $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
93
+            }
92 94
             $sql.= " WHERE s.fournisseur = 1";
93 95
             $sql.= " AND s.entity IN (".getEntity('societe').")";
94
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95
-            if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
96
+            if (!$user->rights->societe->client->voir && !$user->societe_id) {
97
+                $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
98
+            }
99
+            if ($user->societe_id) {
100
+                $sql.= " AND s.rowid = ".$user->societe_id;
101
+            }
96 102
             $sql.= " ORDER BY s.tms DESC ";
97 103
             $sql.= $db->plimit($max, 0);
98 104
 
@@ -131,10 +137,12 @@  discard block
 block discarded – undo
131 137
                     $line++;
132 138
                 }
133 139
 
134
-                if ($num==0) $this->info_box_contents[$line][0] = array(
140
+                if ($num==0) {
141
+                    $this->info_box_contents[$line][0] = array(
135 142
                     'td' => 'align="center"',
136 143
                     'text'=>$langs->trans("NoRecordedSuppliers"),
137 144
                 );
145
+                }
138 146
 
139 147
                 $db->free($result);
140 148
             } else {
Please login to merge, or discard this patch.
dolibarr/htdocs/core/boxes/box_produits_alerte_stock.php 3 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,111 +35,111 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class box_produits_alerte_stock extends ModeleBoxes
37 37
 {
38
-	var $boxcode="productsalertstock";
39
-	var $boximg="object_product";
40
-	var $boxlabel="BoxProductsAlertStock";
41
-	var $depends = array("produit");
38
+    var $boxcode="productsalertstock";
39
+    var $boximg="object_product";
40
+    var $boxlabel="BoxProductsAlertStock";
41
+    var $depends = array("produit");
42 42
 
43
-	/**
43
+    /**
44 44
      * @var DoliDB Database handler.
45 45
      */
46 46
     public $db;
47 47
     
48
-	var $param;
49
-
50
-	var $info_box_head = array();
51
-	var $info_box_contents = array();
52
-
53
-
54
-	/**
55
-	 *  Constructor
56
-	 *
57
-	 *  @param  DoliDB	$db      	Database handler
58
-	 *  @param	string	$param		More parameters
59
-	 */
60
-	function __construct($db,$param='')
61
-	{
62
-	    global $conf,$user;
63
-
64
-	    $this->db = $db;
65
-
66
-	    $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
67
-	    $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock');
68
-	    $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
69
-	    $this->hidden=($showmode != 1);
70
-	}
71
-
72
-	/**
73
-	 *  Load data into info_box_contents array to show array later.
74
-	 *
75
-	 *  @param	int		$max        Maximum number of records to load
48
+    var $param;
49
+
50
+    var $info_box_head = array();
51
+    var $info_box_contents = array();
52
+
53
+
54
+    /**
55
+     *  Constructor
56
+     *
57
+     *  @param  DoliDB	$db      	Database handler
58
+     *  @param	string	$param		More parameters
59
+     */
60
+    function __construct($db,$param='')
61
+    {
62
+        global $conf,$user;
63
+
64
+        $this->db = $db;
65
+
66
+        $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
67
+        $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock');
68
+        $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
69
+        $this->hidden=($showmode != 1);
70
+    }
71
+
72
+    /**
73
+     *  Load data into info_box_contents array to show array later.
74
+     *
75
+     *  @param	int		$max        Maximum number of records to load
76 76
      *  @return	void
77
-	 */
78
-	function loadBox($max=5)
79
-	{
80
-		global $user, $langs, $db, $conf, $hookmanager;
81
-
82
-		$this->max=$max;
83
-
84
-		include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
85
-		$productstatic=new Product($db);
86
-
87
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock",$max));
88
-
89
-		if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire)
90
-		{
91
-			$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,";
92
-			$sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock";
93
-			$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
94
-			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
95
-			$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
96
-			$sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
97
-			if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
98
-			if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
99
-			// Add where from hooks
100
-    		if (is_object($hookmanager))
101
-    		{
102
-			    $parameters=array('boxproductalertstocklist'=>1);
103
-    		    $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
104
-    		    $sql.=$hookmanager->resPrint;
105
-    		}
106
-		    $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity";
107
-			$sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte";
108
-			$sql.= $db->order('p.seuil_stock_alerte', 'DESC');
109
-			$sql.= $db->plimit($max, 0);
110
-
111
-			$result = $db->query($sql);
112
-			if ($result)
113
-			{
114
-				$langs->load("stocks");
115
-				$num = $db->num_rows($result);
116
-				$line = 0;
77
+     */
78
+    function loadBox($max=5)
79
+    {
80
+        global $user, $langs, $db, $conf, $hookmanager;
81
+
82
+        $this->max=$max;
83
+
84
+        include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
85
+        $productstatic=new Product($db);
86
+
87
+        $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock",$max));
88
+
89
+        if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire)
90
+        {
91
+            $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,";
92
+            $sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock";
93
+            $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
94
+            $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
95
+            $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
96
+            $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
97
+            if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
98
+            if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
99
+            // Add where from hooks
100
+            if (is_object($hookmanager))
101
+            {
102
+                $parameters=array('boxproductalertstocklist'=>1);
103
+                $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
104
+                $sql.=$hookmanager->resPrint;
105
+            }
106
+            $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity";
107
+            $sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte";
108
+            $sql.= $db->order('p.seuil_stock_alerte', 'DESC');
109
+            $sql.= $db->plimit($max, 0);
110
+
111
+            $result = $db->query($sql);
112
+            if ($result)
113
+            {
114
+                $langs->load("stocks");
115
+                $num = $db->num_rows($result);
116
+                $line = 0;
117 117
                 while ($line < $num) {
118
-					$objp = $db->fetch_object($result);
119
-					$datem=$db->jdate($objp->tms);
120
-
121
-					// Multilangs
122
-					if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
123
-					{
124
-						$sqld = "SELECT label";
125
-						$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
126
-						$sqld.= " WHERE fk_product=".$objp->rowid;
127
-						$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
128
-						$sqld.= " LIMIT 1";
129
-
130
-						$resultd = $db->query($sqld);
131
-						if ($resultd)
132
-						{
133
-							$objtp = $db->fetch_object($resultd);
134
-							if (isset($objtp->label) && $objtp->label != '')
135
-								$objp->label = $objtp->label;
136
-						}
137
-					}
118
+                    $objp = $db->fetch_object($result);
119
+                    $datem=$db->jdate($objp->tms);
120
+
121
+                    // Multilangs
122
+                    if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
123
+                    {
124
+                        $sqld = "SELECT label";
125
+                        $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
126
+                        $sqld.= " WHERE fk_product=".$objp->rowid;
127
+                        $sqld.= " AND lang='". $langs->getDefaultLang() ."'";
128
+                        $sqld.= " LIMIT 1";
129
+
130
+                        $resultd = $db->query($sqld);
131
+                        if ($resultd)
132
+                        {
133
+                            $objtp = $db->fetch_object($resultd);
134
+                            if (isset($objtp->label) && $objtp->label != '')
135
+                                $objp->label = $objtp->label;
136
+                        }
137
+                    }
138 138
                     $productstatic->id = $objp->rowid;
139 139
                     $productstatic->ref = $objp->ref;
140 140
                     $productstatic->type = $objp->fk_product_type;
141 141
                     $productstatic->label = $objp->label;
142
-					$productstatic->entity = $objp->entity;
142
+                    $productstatic->entity = $objp->entity;
143 143
 
144 144
                     $this->info_box_contents[$line][] = array(
145 145
                         'td' => '',
@@ -156,25 +156,25 @@  discard block
 block discarded – undo
156 156
                     {
157 157
                         $price_base_type=$langs->trans($objp->price_base_type);
158 158
                         $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
159
-	                }
160
-	                else //Parse the dynamic price
161
-	               	{
162
-						$productstatic->fetch($objp->rowid, '', '', 1);
163
-	                    $priceparser = new PriceParser($this->db);
164
-	                    $price_result = $priceparser->parseProduct($productstatic);
165
-	                    if ($price_result >= 0) {
166
-							if ($objp->price_base_type == 'HT')
167
-							{
168
-								$price_base_type=$langs->trans("HT");
169
-							}
170
-							else
171
-							{
172
-								$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
173
-								$price_base_type=$langs->trans("TTC");
174
-							}
175
-							$price=price($price_result);
176
-	                    }
177
-	               	}
159
+                    }
160
+                    else //Parse the dynamic price
161
+                        {
162
+                        $productstatic->fetch($objp->rowid, '', '', 1);
163
+                        $priceparser = new PriceParser($this->db);
164
+                        $price_result = $priceparser->parseProduct($productstatic);
165
+                        if ($price_result >= 0) {
166
+                            if ($objp->price_base_type == 'HT')
167
+                            {
168
+                                $price_base_type=$langs->trans("HT");
169
+                            }
170
+                            else
171
+                            {
172
+                                $price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
173
+                                $price_base_type=$langs->trans("TTC");
174
+                            }
175
+                            $price=price($price_result);
176
+                        }
177
+                        }
178 178
 
179 179
                     $this->info_box_contents[$line][] = array(
180 180
                         'td' => 'class="right"',
@@ -186,16 +186,16 @@  discard block
 block discarded – undo
186 186
                         'text' => $price_base_type,
187 187
                     );
188 188
 
189
-					$this->info_box_contents[$line][] = array(
190
-					    'td' => 'align="center"',
189
+                    $this->info_box_contents[$line][] = array(
190
+                        'td' => 'align="center"',
191 191
                     'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte,
192
-					'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)));
192
+                    'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)));
193 193
 
194
-					$this->info_box_contents[$line][] = array(
195
-					    'td' => 'align="right" width="18"',
194
+                    $this->info_box_contents[$line][] = array(
195
+                        'td' => 'align="right" width="18"',
196 196
                         'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>',
197
-					    'asis' => 1
198
-					);
197
+                        'asis' => 1
198
+                    );
199 199
 
200 200
                     $this->info_box_contents[$line][] = array(
201 201
                         'td' => 'align="right" width="18"',
@@ -211,36 +211,36 @@  discard block
 block discarded – undo
211 211
                         'text'=>$langs->trans("NoTooLowStockProducts"),
212 212
                     );
213 213
 
214
-				$db->free($result);
215
-			}
216
-			else
217
-			{
218
-				$this->info_box_contents[0][0] = array(
214
+                $db->free($result);
215
+            }
216
+            else
217
+            {
218
+                $this->info_box_contents[0][0] = array(
219 219
                     'td' => '',
220 220
                     'maxlength'=>500,
221 221
                     'text' => ($db->error().' sql='.$sql),
222 222
                 );
223
-			}
224
-		}
225
-		else {
223
+            }
224
+        }
225
+        else {
226 226
             $this->info_box_contents[0][0] = array(
227 227
                 'td' => 'align="left" class="nohover opacitymedium"',
228 228
                 'text' => $langs->trans("ReadPermissionNotAllowed")
229 229
             );
230
-		}
231
-	}
232
-
233
-	/**
234
-	 *	Method to show box
235
-	 *
236
-	 *	@param	array	$head       Array with properties of box title
237
-	 *	@param  array	$contents   Array with properties of box lines
238
-	 *  @param	int		$nooutput	No print, only return string
239
-	 *	@return	string
240
-	 */
230
+        }
231
+    }
232
+
233
+    /**
234
+     *	Method to show box
235
+     *
236
+     *	@param	array	$head       Array with properties of box title
237
+     *	@param  array	$contents   Array with properties of box lines
238
+     *  @param	int		$nooutput	No print, only return string
239
+     *	@return	string
240
+     */
241 241
     function showBox($head = null, $contents = null, $nooutput=0)
242 242
     {
243 243
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
244
-	}
244
+    }
245 245
 }
246 246
 
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class box_produits_alerte_stock extends ModeleBoxes
37 37
 {
38
-	var $boxcode="productsalertstock";
39
-	var $boximg="object_product";
40
-	var $boxlabel="BoxProductsAlertStock";
38
+	var $boxcode = "productsalertstock";
39
+	var $boximg = "object_product";
40
+	var $boxlabel = "BoxProductsAlertStock";
41 41
 	var $depends = array("produit");
42 42
 
43 43
 	/**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
 	 *  @param  DoliDB	$db      	Database handler
58 58
 	 *  @param	string	$param		More parameters
59 59
 	 */
60
-	function __construct($db,$param='')
60
+	function __construct($db, $param = '')
61 61
 	{
62
-	    global $conf,$user;
62
+	    global $conf, $user;
63 63
 
64 64
 	    $this->db = $db;
65 65
 
66
-	    $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
67
-	    $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock');
68
-	    $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
69
-	    $this->hidden=($showmode != 1);
66
+	    $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
67
+	    $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock');
68
+	    $showmode = isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
69
+	    $this->hidden = ($showmode != 1);
70 70
 	}
71 71
 
72 72
 	/**
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 	 *  @param	int		$max        Maximum number of records to load
76 76
      *  @return	void
77 77
 	 */
78
-	function loadBox($max=5)
78
+	function loadBox($max = 5)
79 79
 	{
80 80
 		global $user, $langs, $db, $conf, $hookmanager;
81 81
 
82
-		$this->max=$max;
82
+		$this->max = $max;
83 83
 
84 84
 		include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
85
-		$productstatic=new Product($db);
85
+		$productstatic = new Product($db);
86 86
 
87
-		$this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock",$max));
87
+		$this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max));
88 88
 
89 89
 		if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire)
90 90
 		{
91 91
 			$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,";
92
-			$sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock";
93
-			$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
94
-			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
95
-			$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
96
-			$sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
97
-			if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
98
-			if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
92
+			$sql .= " SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock";
93
+			$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
94
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
95
+			$sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
96
+			$sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
97
+			if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0';
98
+			if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1';
99 99
 			// Add where from hooks
100 100
     		if (is_object($hookmanager))
101 101
     		{
102
-			    $parameters=array('boxproductalertstocklist'=>1);
103
-    		    $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
104
-    		    $sql.=$hookmanager->resPrint;
102
+			    $parameters = array('boxproductalertstocklist'=>1);
103
+    		    $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
104
+    		    $sql .= $hookmanager->resPrint;
105 105
     		}
106
-		    $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity";
107
-			$sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte";
108
-			$sql.= $db->order('p.seuil_stock_alerte', 'DESC');
109
-			$sql.= $db->plimit($max, 0);
106
+		    $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity";
107
+			$sql .= " HAVING SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte";
108
+			$sql .= $db->order('p.seuil_stock_alerte', 'DESC');
109
+			$sql .= $db->plimit($max, 0);
110 110
 
111 111
 			$result = $db->query($sql);
112 112
 			if ($result)
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 				$line = 0;
117 117
                 while ($line < $num) {
118 118
 					$objp = $db->fetch_object($result);
119
-					$datem=$db->jdate($objp->tms);
119
+					$datem = $db->jdate($objp->tms);
120 120
 
121 121
 					// Multilangs
122
-					if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
122
+					if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
123 123
 					{
124 124
 						$sqld = "SELECT label";
125
-						$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
126
-						$sqld.= " WHERE fk_product=".$objp->rowid;
127
-						$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
128
-						$sqld.= " LIMIT 1";
125
+						$sqld .= " FROM ".MAIN_DB_PREFIX."product_lang";
126
+						$sqld .= " WHERE fk_product=".$objp->rowid;
127
+						$sqld .= " AND lang='".$langs->getDefaultLang()."'";
128
+						$sqld .= " LIMIT 1";
129 129
 
130 130
 						$resultd = $db->query($sqld);
131 131
 						if ($resultd)
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
                     if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression))
156 156
                     {
157
-                        $price_base_type=$langs->trans($objp->price_base_type);
158
-                        $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
157
+                        $price_base_type = $langs->trans($objp->price_base_type);
158
+                        $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc);
159 159
 	                }
160 160
 	                else //Parse the dynamic price
161 161
 	               	{
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 	                    if ($price_result >= 0) {
166 166
 							if ($objp->price_base_type == 'HT')
167 167
 							{
168
-								$price_base_type=$langs->trans("HT");
168
+								$price_base_type = $langs->trans("HT");
169 169
 							}
170 170
 							else
171 171
 							{
172 172
 								$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
173
-								$price_base_type=$langs->trans("TTC");
173
+								$price_base_type = $langs->trans("TTC");
174 174
 							}
175
-							$price=price($price_result);
175
+							$price = price($price_result);
176 176
 	                    }
177 177
 	               	}
178 178
 
@@ -188,24 +188,24 @@  discard block
 block discarded – undo
188 188
 
189 189
 					$this->info_box_contents[$line][] = array(
190 190
 					    'td' => 'align="center"',
191
-                    'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte,
191
+                    'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte,
192 192
 					'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)));
193 193
 
194 194
 					$this->info_box_contents[$line][] = array(
195 195
 					    'td' => 'align="right" width="18"',
196
-                        'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>',
196
+                        'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell, 3, 0).'<span>',
197 197
 					    'asis' => 1
198 198
 					);
199 199
 
200 200
                     $this->info_box_contents[$line][] = array(
201 201
                         'td' => 'align="right" width="18"',
202
-                        'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy,3,0).'<span>',
202
+                        'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy, 3, 0).'<span>',
203 203
                         'asis' => 1
204 204
                     );
205 205
 
206 206
                     $line++;
207 207
                 }
208
-                if ($num==0)
208
+                if ($num == 0)
209 209
                     $this->info_box_contents[$line][0] = array(
210 210
                         'td' => 'align="center"',
211 211
                         'text'=>$langs->trans("NoTooLowStockProducts"),
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 *  @param	int		$nooutput	No print, only return string
239 239
 	 *	@return	string
240 240
 	 */
241
-    function showBox($head = null, $contents = null, $nooutput=0)
241
+    function showBox($head = null, $contents = null, $nooutput = 0)
242 242
     {
243 243
         return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
244 244
 	}
Please login to merge, or discard this patch.
Braces   +19 added lines, -15 removed lines patch added patch discarded remove patch
@@ -94,8 +94,12 @@  discard block
 block discarded – undo
94 94
 			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
95 95
 			$sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
96 96
 			$sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
97
-			if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
98
-			if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
97
+			if (empty($user->rights->produit->lire)) {
98
+			    $sql.=' AND p.fk_product_type != 0';
99
+			}
100
+			if (empty($user->rights->service->lire)) {
101
+			    $sql.=' AND p.fk_product_type != 1';
102
+			}
99 103
 			// Add where from hooks
100 104
     		if (is_object($hookmanager))
101 105
     		{
@@ -119,9 +123,11 @@  discard block
 block discarded – undo
119 123
 					$datem=$db->jdate($objp->tms);
120 124
 
121 125
 					// Multilangs
122
-					if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
126
+					if (! empty($conf->global->MAIN_MULTILANGS)) {
127
+					    // si l'option est active
123 128
 					{
124 129
 						$sqld = "SELECT label";
130
+					}
125 131
 						$sqld.= " FROM ".MAIN_DB_PREFIX."product_lang";
126 132
 						$sqld.= " WHERE fk_product=".$objp->rowid;
127 133
 						$sqld.= " AND lang='". $langs->getDefaultLang() ."'";
@@ -131,8 +137,9 @@  discard block
 block discarded – undo
131 137
 						if ($resultd)
132 138
 						{
133 139
 							$objtp = $db->fetch_object($resultd);
134
-							if (isset($objtp->label) && $objtp->label != '')
135
-								$objp->label = $objtp->label;
140
+							if (isset($objtp->label) && $objtp->label != '') {
141
+															$objp->label = $objtp->label;
142
+							}
136 143
 						}
137 144
 					}
138 145
                     $productstatic->id = $objp->rowid;
@@ -156,8 +163,7 @@  discard block
 block discarded – undo
156 163
                     {
157 164
                         $price_base_type=$langs->trans($objp->price_base_type);
158 165
                         $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
159
-	                }
160
-	                else //Parse the dynamic price
166
+	                } else //Parse the dynamic price
161 167
 	               	{
162 168
 						$productstatic->fetch($objp->rowid, '', '', 1);
163 169
 	                    $priceparser = new PriceParser($this->db);
@@ -166,8 +172,7 @@  discard block
 block discarded – undo
166 172
 							if ($objp->price_base_type == 'HT')
167 173
 							{
168 174
 								$price_base_type=$langs->trans("HT");
169
-							}
170
-							else
175
+							} else
171 176
 							{
172 177
 								$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
173 178
 								$price_base_type=$langs->trans("TTC");
@@ -205,15 +210,15 @@  discard block
 block discarded – undo
205 210
 
206 211
                     $line++;
207 212
                 }
208
-                if ($num==0)
209
-                    $this->info_box_contents[$line][0] = array(
213
+                if ($num==0) {
214
+                                    $this->info_box_contents[$line][0] = array(
210 215
                         'td' => 'align="center"',
211 216
                         'text'=>$langs->trans("NoTooLowStockProducts"),
212 217
                     );
218
+                }
213 219
 
214 220
 				$db->free($result);
215
-			}
216
-			else
221
+			} else
217 222
 			{
218 223
 				$this->info_box_contents[0][0] = array(
219 224
                     'td' => '',
@@ -221,8 +226,7 @@  discard block
 block discarded – undo
221 226
                     'text' => ($db->error().' sql='.$sql),
222 227
                 );
223 228
 			}
224
-		}
225
-		else {
229
+		} else {
226 230
             $this->info_box_contents[0][0] = array(
227 231
                 'td' => 'align="left" class="nohover opacitymedium"',
228 232
                 'text' => $langs->trans("ReadPermissionNotAllowed")
Please login to merge, or discard this patch.